For example if I am searching for a key with a value 5
in my array $cake
, I could use the following code:
$cake = array("a"=>6,"b"=>5,"c"=>6);
echo array_search(5, $cake, true); // returns "b";
But if my $cake
array contains multiple matches, only the first match is returned:
$cake = array("a"=>6,"b"=>5,"c"=>5,"d"=>5,"e"=>5);
echo array_search(5, $cake, true); // returns "b";
How can I return multiple matches as an array? Like this:
$cake = array("a"=>6,"b"=>5,"c"=>5,"d"=>5,"e"=>5);
// return array("b","c","d","e");