Monday 3 September 2018
Subscribe to:
Post Comments (Atom)
foreach
, then a while
->list, etc procedure, (I have already accomplished it), however I sense that my code is a bit dirty and it doesn't look like the best solution... I'm looking to use native PHP array functions to do the following:[0] (Array)#2 [rank] "579" [id] "1" [1] (Array)#4 [rank] "251" [id] "2" [0] (Array)#2 [size] "S" [status] "A" [id] "1" [1] (Array)#15 [size] "L" [status] "A" [id] "2"
[0] (Array)#2 [size] "S" [status] "A" [id] "1" [rank] "579" [1] (Array)#2 [size] "L" [status] "A" [id] "2" [rank] "251"
id
value (or ay other) without going into a endless set of foreach
s?$array = array_merge_recursive($array1, $array2);
function my_array_merge(&$array1, &$array2) {
$result = Array();
foreach($array1 as $key => &$value) {
$result[$key] = array_merge($value, $array2[$key]);
}
return $result;
}
$array = my_array_merge($array1, array2);
print_r($array);
Hello Friends! I am Ramana a part time blogger from Hyderabad.
0 comments:
Post a Comment