例如,如果我5
在我的数组中搜索具有值的键$cake
,我可以使用以下代码:
$cake = array("a"=>6,"b"=>5,"c"=>6);
echo array_search(5, $cake, true); // returns "b";
但如果我的$cake
数组包含多个匹配项,则只返回第一个匹配项:
$cake = array("a"=>6,"b"=>5,"c"=>5,"d"=>5,"e"=>5);
echo array_search(5, $cake, true); // returns "b";
如何将多个匹配项作为数组返回?像这样:
$cake = array("a"=>6,"b"=>5,"c"=>5,"d"=>5,"e"=>5);
// return array("b","c","d","e");