note 92427 deleted from function.in-array by bjori
| From: | bjori@php.net | Date: | Fri, 01 Jan 2010 17:32:15 +0000 |
| Subject: | note 92427 deleted from function.in-array by bjori | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-164514@lists.php.net to get a copy of this message | ||
Note Submitter: brianko
----
in_array() and array_search() are not identical. While trying to track down a bug, I discovered
that this would produce a match:
<?php
$raw_data_item_types = array(0,5,9,'g','I');
$item="?gopher"
if(true===in_array($item, $raw_item_types))
{
// ...
}
?>
Obviously not the desired result! Replacing all instances of in_array with array_search() solved
the immediate problem of not producing a match when there wasn't one to begin with.