I have an array like this how had same gtin:
Array
(
[0]
(
[status] => ERROR
[message] => 'message error'
[gtin] => 03661733003170
)
[1]
(
[status] => SUCCESS
[message] =>
[gtin] => 03661985096630
)
)
and another array like this:
Array
(
[0] => Array
(
[e_id] => 219
[v_id] => 20
[gtin] => 03661733003170
)
[1] => Array
(
[e_id] => 217
[v_id] => 15
[gtin] => 03661985096630
)
)
I want to combine this two array in one array how has the same gtin like this I have try lot of php function but nothing resold my problem:
Array
(
[03661733003170]
(
[status] => ERROR
[message] => 'message error'
[e_id] => 219,
[v_id] => 20
)
[03661985096630]
(
[status] => SUCCESS
[message] =>
[evt_id] => 217,
[evl_id] => 15
)
)
thank for help
Assuming that all keys are numeric and iteritable and that both arrays are of equal length, a simple loop with array_merge() is probably your best bet.
$myarray1 = ....
$myarray2 = ....
$resultarray = array();
for ($i = 0; $i == sizeof($myarray1); $i++) {
$resultarray[$i] = array_merge($myarray1[$i], $myarray2[$i]);
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.