我想基於pid和大小s更新數組,如果產品id和大小都匹配相同的數組元素,那麼它通過添加數量並將它們合併到一個索引中來更新數量。任何幫助都應該不勝感激。
我的代碼是:_更新php多維數組
<?php
$details = array ("0" => array ("pid" => "402",
"q" => "1",
"s" => "0"
),
"1" => array ("pid" => "403",
"q" => "2",
"s" => "0"
),
"2" => array ("pid" => "402",
"q" => "3",
"s" => "0"
),
"3" => array ("pid" => "403",
"q" => "1",
"s" => "0"
),
"4" => array ("pid" => "405",
"q" => "1",
"s" => "0"
),
);
?>
輸出應該看起來像
輸出:
0-pid 402 q 4 s 0
1-pid 403 q 3 s 0
4-pid 405 q 1 s 0
在請求免費代碼之前,請先付出一些努力。 – ToBe 2014-08-28 09:11:05