note 57991 added to function.in-array

From: Date: Thu, 20 Oct 2005 21:48:38 +0000
Subject: note 57991 added to function.in-array
Groups: php.notes 
Request: Send a blank email to php-notes+get-97327@lists.php.net to get a copy of this message
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; } ?> ---- Manual Page -- http://www.php.net/manual/en/function.in-array.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+57991 Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+57991&report=yes&reason=added+to+the+manual Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+57991&report=yes&reason=bad+code Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+57991&report=yes&reason=spam Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+57991&report=yes&reason=useless Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+57991&report=yes&reason=non-english Delete: already in docs -- http://master.php.net/manage/user-notes.php?action=delete+57991&report=yes&reason=already+in+docs Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+57991&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+57991&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#97327) next »