note 57991 deleted from function.in-array by felipe

From: Date: Sun, 30 Dec 2007 18:57:52 +0000
Subject: note 57991 deleted from function.in-array by felipe
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-134485@lists.php.net to get a copy of this message
Note Submitter: adunaphel at il dot fontys dot nl ---- a rewrite of alex at alexelectronics dot com's code, with the strict option added and some slight improvements in speed and readability: <?php function in_multi_array ($needle, $haystack, $strict) { if ($strict) { foreach ($haystack as $item) { if (is_array ($item)) { if (in_multi_array ($needle, $item, $strict)) { return true; } } else { if ($needle === $item) { return true; } } } } else { foreach ($haystack as $item) { if (is_array ($item)) { if (in_multi_array ($needle, $item, $strict)) { return true; } } else { if ($needle == $item) { return true; } } } } return false; } ?>

« previous php.notes (#134485) next »