note 85259 added to function.array-search
| From: | gries at osu1 dot php dot net | Date: | Fri, 22 Aug 2008 09:59:18 +0000 |
| Subject: | note 85259 added to function.array-search | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-143741@lists.php.net to get a copy of this message | ||
Hey,
never forget to read the manual -.-.
if you use array_search dont try to use:
<?php
if(!array_search("findme",$array))
?>
THIS WILL NOT WORK.
because if you have an array like this:
<?php
Array(
[0] => uid,
[1] => givenName,
[2] => sn,
[3] => cn
);
?>
array search like this:
<?php
array_search("uid",$array);
?>
will return false because 0 is returned
you have to check the return value like this
<?php
if(array_search("uid",$array)===false)
?>
----
Server IP: 81.223.48.75
Probable Submitter: 213.235.230.98
----
Manual Page -- http://www.php.net/manual/en/function.array-search.php
Edit -- https://master.php.net/note/edit/85259
Del: integrated -- https://master.php.net/note/delete/85259/integrated
Del: useless -- https://master.php.net/note/delete/85259/useless
Del: bad code -- https://master.php.net/note/delete/85259/bad+code
Del: spam -- https://master.php.net/note/delete/85259/spam
Del: non-english -- https://master.php.net/note/delete/85259/non-english
Del: in docs -- https://master.php.net/note/delete/85259/in+docs
Del: other reasons-- https://master.php.net/note/delete/85259
Reject -- https://master.php.net/note/reject/85259
Search -- https://master.php.net/manage/user-notes.php