I know many questions already asked about this problem, but I was not able to find the right answer for my specific problem.
I have a search string - "1|1"
I have a array containing following values - "a" => "1|1", "b" => "2|1,1|1", "c" => "3|2,2|1"
All I want to do is just to find if the search string existed in the array, it should return the array key. If more than one array item has the search string, it should return all of them.
In this example, I am expecting to get both "a" and "b", but when I use strpos(), it only gives me "a".
How can I solve this problem?
Edit**
This is my code
function array_search_i($str, $array)
{
$returnArray = array();
foreach ($array as $key => $value) {
if (strpos($str, $value) !== false) {
array_push($returnArray, $key);
}
}
return $returnArray;
}