Answers for "array merge with same key in php"

PHP
0

merge two arrays one as key to another php

// two arrays one become keys and second becomes values
array_combine ( array $keys , array $values );
Posted by: Guest on November-02-2020
0

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;
}
Posted by: Guest on August-07-2020
0

php combine values of two arrays

$all_arrays = array_merge($array1, $array2, $array3, ...);
Posted by: Guest on October-31-2020
0

array merge with same key in php

Input : $a1=array("a"=>"raj", "b"=>"striver");
        $a2=array("z"=>"geeks", "b"=>"articles");
Output : 
Array
(
    [a] => raj
    [b] => Array
        (
            [0] => striver
            [1] => articles
        )

    [z] => geeks
)
Posted by: Guest on April-28-2020

Code answers related to "array merge with same key in php"

Browse Popular Code Answers by Language