<?php
$arr = array("purchase_order_details_id"=>array(
0=>"POD1",
1=>"POD1",
2=>"POD2",
),
"quantity_received"=>array(
0=>5,
1=>10,
2=>20
)
);
$pods = array_unique($arr["purchase_order_details_id"]);
Foreach($pods as $pod){
$PO = array_intersect($arr["purchase_order_details_id"], [$pod]);
$qt = array_intersect_key($arr["quantity_received"], $PO);
$new[$pod] = ["purchase_order_details_id" => $PO, "quantity_received" => $qt];
}
Var_dump($new);
extract($new);
- Output for 5.6.0 - 5.6.40, 7.0.0 - 7.0.33, 7.1.0 - 7.1.33, 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.30, 8.2.0 - 8.2.25, 8.3.0 - 8.3.13
- array(2) {
["POD1"]=>
array(2) {
["purchase_order_details_id"]=>
array(2) {
[0]=>
string(4) "POD1"
[1]=>
string(4) "POD1"
}
["quantity_received"]=>
array(2) {
[0]=>
int(5)
[1]=>
int(10)
}
}
["POD2"]=>
array(2) {
["purchase_order_details_id"]=>
array(1) {
[2]=>
string(4) "POD2"
}
["quantity_received"]=>
array(1) {
[2]=>
int(20)
}
}
}
preferences:
66.34 ms | 409 KiB | 5 Q