こんにちは、私はこのような配列を持っています:
0 =>
array (size=6)
'id' => string '55' (length=2)
'uid' => string '1' (length=1)
'item_id' => string '5' (length=1)
'item_name' => string 'dfgdfg' (length=6)
'price' => string '14.91' (length=5)
'time' => string '1373975023' (length=10)
1 =>
array (size=6)
'id' => string '59' (length=2)
'uid' => string '1' (length=1)
'item_id' => string '5' (length=1)
'item_name' => string 'dfgdfg' (length=6)
'price' => string '14.91' (length=5)
'time' => string '1373978756' (length=10)
2 =>
array (size=6)
'id' => string '58' (length=2)
'uid' => string '1' (length=1)
'item_id' => string '6' (length=1)
'item_name' => string 'kubek #1' (length=8)
'price' => string '10.01' (length=5)
'time' => string '1373978751' (length=10)
3 =>
array (size=6)
'id' => string '56' (length=2)
'uid' => string '1' (length=1)
'item_id' => string '7' (length=1)
'item_name' => string 'ewr' (length=3)
'price' => string '1.05' (length=4)
'time' => string '1373975032' (length=10)
そして、この配列を次のようなものに変える必要があります:
0 =>
array (size=6)
'id' => string '59' (length=2)
'uid' => string '1' (length=1)
'item_id' => string '5' (length=1)
'item_name' => string 'dfgdfg' (length=6)
'price' => string '14.91' (length=5)
'time' => string '1373978756' (length=10)
'q' => 2
1 =>
array (size=6)
'id' => string '58' (length=2)
'uid' => string '1' (length=1)
'item_id' => string '6' (length=1)
'item_name' => string 'kubek #1' (length=8)
'price' => string '10.01' (length=5)
'time' => string '1373978751' (length=10)
'q' => 1
2 =>
array (size=6)
'id' => string '56' (length=2)
'uid' => string '1' (length=1)
'item_id' => string '7' (length=1)
'item_name' => string 'ewr' (length=3)
'price' => string '1.05' (length=4)
'time' => string '1373975032' (length=10)
'q' => 1
配列に含まれる特定の値の数を数え、それらを新しい値に配置する必要があります。現時点では、この方法でこれを実行しようとしていますが、うまく機能しません
foreach ($b as $k => $v) {
$bas[$k]['q'] = array_count_values($v['item_id']);
}