I need to add a preg_match condition to this function below. The function is used to see if variable exists in a 2d array.
function in_multi_array($needle, $haystack) //taken from php.net, adapted
{
$in_multi_array = false;
if(in_array($needle, $haystack))
{
$in_multi_array = true;
}
else
{
while (list($tmpkey,$tmpval) = each ($haystack))
//here is the change
{
if(is_array($haystack[$tmpkey]))
{
if (in_multi_array($needle, $haystack[$tmpkey]))
{
$in_multi_array = true;
break;
}}}}
return $in_multi_array;
}
I want to add the following but am not sure how?
$needle = 'Apple, banana and pear';
$test = preg_match('/apple/', $needle, $match);
I want there to be a true/false out come from $match.
Any ideas?
Jamie