RonnyNishimoto
07-29-2012, 06:52 AM
I'm using:
function in_array_multi($needle, $haystack) {
foreach ($haystack as $item) {
if ($item === $needle || (is_array($item) && in_array_multi($needle, $item))) {
return true;
}
}
return false;
}
If the needle is in the 2nd array, return the name of the array.
IE:
$candy = array("chocolate" => array("snicker","musketeer"));
if musketeer is found, return chocolate
How can I do this? If not possible, how with just an associative array?
function in_array_multi($needle, $haystack) {
foreach ($haystack as $item) {
if ($item === $needle || (is_array($item) && in_array_multi($needle, $item))) {
return true;
}
}
return false;
}
If the needle is in the 2nd array, return the name of the array.
IE:
$candy = array("chocolate" => array("snicker","musketeer"));
if musketeer is found, return chocolate
How can I do this? If not possible, how with just an associative array?