我有此數組:搜索數組中的
$fruits = array(
[0] => array('name'=>'banana', 'color'=>'yellow' , 'shape'=>'cylinder'),
[1] => array('name'=>'apple', 'color'=>'red' , 'shape'=>'sphere'),
[2] => array('name'=>'orange', 'color'=>'orange' , 'shape'=>'sphere')
)
我如何找出如果數組$fruits
已經包含在它apple
?
我試過:in_array("apple", $fruits)
,那沒有奏效。
我也嘗試了各種語法,並與array_key_exists()
搞砸了一點,但沒有任何結果。有任何想法嗎?
您可以用'in_array();' –
我試過in_array(),我想最好的解決方案,佔所有我得到的答案是foreach循環.. – Mustapha
結帳我的答案。我使用了'foreach()'和'in_array()' –