I have a multi-line array value setup in existing code (written by an former team member) as follows:
$array1['Alpha'] = "New York,Los Angeles,Washington";
$array1['Beta'] = "New York,Los Angeles,Honolulu";
$array1['Gamma'] = "New York,Los Angeles,Washington";
....
....
and so on....
My need is that I have the value of a city (say "Washington"), and I need to get all the array index values which have Washington in their CSV list. So in the above case, the answer would be "Alpha" and "Gamma" (but not "Beta" as it does not contain Washington)
I tried array_search function, like
echo array_search("Washington",$array1);
but it is not yielding the desired result.
What am I missing here please?
Also tried
$cittskarray = explode(',', $array1["Washington"]);
foreach ($array1 as $cityvalue)
{
;//search one by one
}
but that is lengthy method and does deep search.
Washington