note 16345 added to function.array-search
| From: | jeffct at example dot com | Date: | Thu, 25 Oct 2001 15:26:57 +0000 |
| Subject: | note 16345 added to function.array-search | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-19426@lists.php.net to get a copy of this message | ||
In response to kerry@lothrop.de and anyone else posting homemade array_search functions using
foreach, you have defeated the purpose.
The original purpose was to have a PHP3 compatible array_search function. But foreach and
array_keys() are only available in PHP4.
For a PHP3 compatible search function you need to use:
reset($array);
while(list($key,$value) = each($array))
Instead of the foreach() loop
--
http://www.php.net/manual/en/function.array-search.php
http://master.php.net/manage/user-notes.php?action=edit+16345
http://master.php.net/manage/user-notes.php?action=delete+16345
http://master.php.net/manage/user-notes.php?action=reject+16345