$a = Array
(
'orderNo'=> 1604091519275112,
'originalOrderNo' => 71341902143574,
'createTime'=> 1460186349,
'details' => Array
(
Array
(
'gno' => 'ds1-sp1',
'ebcID'=>1,
'weight' => 123.000,
'netWeight' => 123.000
),
Array
(
'gno' => 'ds1-sp1',
'ebcID'=>2,
'weight' => 123.000,
'netWeight' => 123.000
),
Array
(
'gno' => ds1-sp1,
'ebcID'=>1,
'weight' => 123.000,
'netWeight' => 123.000
),
Array
(
'gno' => 'ds1-sp1',
'ebcID'=>4,
'weight' => 123.000,
'netWeight' => 123.000
),
)
);
$target = array();
$temp = array();
foreach ($a['details'] as $val) {
$target[$val['ebcID']][] = $val;
}
echo "
";
print_r($target);
foreach ($a['details'] as $val) {
if (!empty($target)) {
if (in_array($val['ebcID'], array_keys($target))) {
//if (!empty($temp[$val['ebcID']])) {
//$target[$val['target_id']] = null;
$target[$val['ebcID']][] = $val;
//$temp[$val['target_id']] = null;
//}
} else {
$temp[$val['ebcID']][] = $val;
$target[$val['ebcID']][] = $val;
}
} else {
$temp[$val['ebcID']][] = $val;
$target[$val['ebcID']][] = $val;
}
}