note 92436 added to function.in-array
| From: | mwm03c at fsu dot edu | Date: | Fri, 24 Jul 2009 04:29:47 +0000 |
| Subject: | note 92436 added to function.in-array | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-158673@lists.php.net to get a copy of this message | ||
@brianko: as john just mentioned below, in_array() was recognizing that string in your array because
strings seem to evaluate to 0 when they begin with non-digits (so "?gopher" was matched to
0). Adding the optional strict parameter (ex. in_array($item, $raw_item_types, true)) would have
fixed the problem because then "?gopher" !== 0.
You also have two bugs in your code:
1. missing ";" after assigning "?gopher" to $item
2. $raw_data_item_types is assigned the array, but $item is checked against $raw_item_types - an
uninitialized variable
----
Server IP: 209.41.74.194
Probable Submitter: 68.35.246.31
----
Manual Page -- http://www.php.net/manual/en/function.in-array.php
Edit -- https://master.php.net/note/edit/92436
Del: integrated -- https://master.php.net/note/delete/92436/integrated
Del: useless -- https://master.php.net/note/delete/92436/useless
Del: bad code -- https://master.php.net/note/delete/92436/bad+code
Del: spam -- https://master.php.net/note/delete/92436/spam
Del: non-english -- https://master.php.net/note/delete/92436/non-english
Del: in docs -- https://master.php.net/note/delete/92436/in+docs
Del: other reasons-- https://master.php.net/note/delete/92436
Reject -- https://master.php.net/note/reject/92436
Search -- https://master.php.net/manage/user-notes.php