我想按關鍵性別和鑰匙RNAME從以下關聯數組數二的鍵 - >值過濾器,請參考下面...陣列計數誤差
<pre>
Array
(
[0] => Array
(
[fname] => jone
[lname] => jani
[gender] => m
[rname] => N
)
[1] => Array
(
[fname] => jani
[lname] => jone
[gender] => m
[rname] => N
)
[2] => Array
(
[fname] => sara
[lname] => bulbula
[gender] => w
[rname] => D
)
[3] => Array
(
[fname] => hani
[lname] => hanu
[gender] => w
[rname] => P
)
[4] => Array
(
[fname] => ttttttt
[lname] => sssssss
[gender] => m
[rname] => C
)
)
</pre>
我想要的是什麼結果如下..
rname gender m w N 2 0 D 0 1 P 0 1 C 1 0 total 3 2
有些幫助嗎?
所以哪裏是你的代碼有錯誤? – bitWorking
我可以指望只在一個鍵值...但我有兩種。我使用這個小功能coudn't,但只在一個Key..public功能array_column($數組$鍵){$ 場計數=陣列(); 的foreach($數組作爲$ realKey => $值){ 如果(isset($值[$鍵])){$ 領域[$ realKey] = $值[$鍵]。 } } return $ field; } –