The code below doesn’t seem to work or find anything on an array. I’m using “in_array” to search for the needle in the stack. I also tried exploding the contents with comma separated and won’t work. Any suggestions? Also I tried “array_search”.
$q4 = "SELECT domain_name,slots_config.bid FROM slots_pid,slots_config,slots_sites
WHERE slots_config.bid=slots_pid.bid && slots_sites.aid=slots_pid.aid";
$result4 = mysql_query($q4);
while($row = mysql_fetch_array($result4))
{
$resultarray[] = $row;
}
if (in_array("test",$resultarray))
{
echo "Match found";
}
else
{
echo "Match not found";
}
in_array()won’t work with that sort of array, because it’s multi-dimensional.Your array looks like this:
You can’t use
in_array()to search in that, so you’ll have to do it with another method, something like looping over the array, or building$resultarraydifferently.Similarly,
array_search()doesn’t work on multidimensional arrays, so you could do something like looping over the first dimension andarray_search()-ing each second dimension.Let me know if you want more detail.