Search
 
SCRIPT & CODE EXAMPLE
 

PHP

php merge 2 arrays

<?php
  $array1 = [
      "color" => "green"
  ];
  $array2 = [
      "color" => "red", 
      "color" => "blue"
  ];
  $result = array_merge($array1, $array2);
?>

// $result
[
    "color" => "green"
    "color" => "red", 
    "color" => "blue"
]
Comment

php combine values of two arrays

$all_arrays = array_merge($array1, $array2, $array3, ...);
Comment

php merge array with same value

function custom_array_merge(&$array1, &$array2) {
    $result = Array();
    foreach ($array1 as $key_1 => &$value_1) {
        // if($value['name'])
        foreach ($array2 as $key_1 => $value_2) {
            if($value_1['name'] ==  $value_2['name']) {
                $result[] = array_merge($value_1,$value_2);
            }
        }

    }
    return $result;
}
Comment

PREVIOUS NEXT
Code Example
Php :: how to sort with array and after print by for loop in php 
Php :: PHP MySQL Use The WHERE Clause 
Php :: check the route type in laravel 
Php :: php str replace 
Php :: laravel app running in console 
Php :: php header x forwarder for 
Php :: laravel file store 
Php :: filter array in php with passing extra params 
Php :: declare variable in php class 
Php :: php file_put_contents inode problem 
Php :: update column type laravel migration 
Php :: create symfony 4 project 
Php :: Update First and Last Day of Previous Month with Carbon 
Php :: luhn algorithm credit card checker php 
Php :: sendmail php 
Php :: echo in console command laravel 
Php :: IlluminateContractsAuthAuthenticatable, AppModelsUser given, called in 
Php :: add object in array php 
Php :: laravel chunk 
Php :: change default user table name laravel 
Php :: php check if valid xml 
Php :: laravel hash 
Php :: clear cache in laravel without artisan 
Php :: read pdf text php 
Php :: how to create static variable in model laravel 
Php :: php if time is greater than 
Php :: strrev php 
Php :: switch between php version ubuntu 
Php :: how to create constant in php 
Php :: woocommerce update_status 
ADD CONTENT
Topic
Content
Source link
Name
6+5 =