note 73515 added to function.in-array
| From: | ben at osu1 dot php dot net | Date: | Tue, 27 Feb 2007 09:25:27 +0000 |
| Subject: | note 73515 added to function.in-array | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-123919@lists.php.net to get a copy of this message | ||
Becareful :
$os = array ("Mac", "NT", "Irix", "Linux");
if ( in_array(0, $os ) )
echo 1 ;
else
echo 2 ;
This code will return 1 instead of 2 as you would waiting for.
So don't forget to add the TRUE parameter :
if ( in_array(0, $os ) )
echo 1 ;
else
echo 2 ;
Thie time it will return 2.
----
Server IP: 217.174.196.197
Probable Submitter: 81.80.172.141
----
Manual Page -- http://www.php.net/manual/en/function.in-array.php
Edit -- https://master.php.net/note/edit/73515
Del: integrated -- https://master.php.net/note/delete/73515/integrated
Del: useless -- https://master.php.net/note/delete/73515/useless
Del: bad code -- https://master.php.net/note/delete/73515/bad+code
Del: spam -- https://master.php.net/note/delete/73515/spam
Del: non-english -- https://master.php.net/note/delete/73515/non-english
Del: in docs -- https://master.php.net/note/delete/73515/in+docs
Del: other reasons-- https://master.php.net/note/delete/73515
Reject -- https://master.php.net/note/reject/73515
Search -- https://master.php.net/manage/user-notes.php