Answers for "how to combine two index ff same array if both have same id php"

PHP
3

how to add two array in single array without repetation in php

<?php
	$array1=array("CPU","Mouse","Monitor");
	$array2=array("Key-Board","Monitor","Printer");
	$array = array_unique(array_merge($array1, $array2));
	print_r($array);
?>
Posted by: Guest on October-24-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

Code answers related to "how to combine two index ff same array if both have same id php"

Browse Popular Code Answers by Language