[0]=>array(3) {
["Number"]=> "L1"
["Location"]=> "Location-A"
["Qty"]=>"1"
}
[1]=>array(3) {
["Number"]=> "L1"
["Location"]=> "Location-B"
["Qty"]=> "5"
}
[2]=> array(3) {
["Number"]=> "L1"
["Location"]=> "Location-B"
["Qty"]=> "4"
}
[3]=>array(3) {
["Number"]=> "L2"
["Location"]=> "Location-B"
["Qty"]=> "5"
}
的陣列結構,但我需要以下的結構輸出中
[0]=>array(3) {
["Number"]=> "L1"
["Location"]=> "Location-A"
["Qty"]=>"1"
}
[1]=> array(3) {
["Number"]=> "L1"
["Location"]=> "Location-B"
["Qty"]=> "4"
}
[2]=>array(3) {
["Number"]=> "L2"
["Location"]=> "Location-B"
["Qty"]=> "5"
}
我如何可以按編號刪除重複值,位置?
ksort只適用於一個值,我需要刪除兩個值,我怎麼能實現這個PHP?
$ordered = array();
foreach ($data as $da)
{
$ordered[$da['Number']] = $da;
$ordered[$da['Location']] = $da;
}
ksort($ordered);
你怎麼知道保留哪一個? – RST
創建一個新數組:array_tmp(),並使用'array_push()'插入並比較數字和位置。 – EngineerCoder
這個問題是鬆散版本的http://stackoverflow.com/questions/27526145/delete-duplicate-on-multidimensional-array-and-take-those-having-highest-value-i – axiac