note 95337 added to function.in-array

From: Date: Mon, 28 Dec 2009 08:50:58 +0000
Subject: note 95337 added to function.in-array
Groups: php.notes 
Request: Send a blank email to php-notes+get-164376@lists.php.net to get a copy of this message
brianko noted that 'string' is in array(0). This is because all strings are evaluated to 0. Such matches can be avoided by using the strict flag. <?php $haystack = array( 0 ); $needle = 'string'; in_array( $needle, $haystack ); // => true in_array( $needle, $haystack, true ); // => false ?> ---- Server IP: 194.236.124.41 Probable Submitter: 80.252.190.5 ---- Manual Page -- http://www.php.net/manual/en/function.in-array.php Edit -- https://master.php.net/note/edit/95337 Del: integrated -- https://master.php.net/note/delete/95337/integrated Del: useless -- https://master.php.net/note/delete/95337/useless Del: bad code -- https://master.php.net/note/delete/95337/bad+code Del: spam -- https://master.php.net/note/delete/95337/spam Del: non-english -- https://master.php.net/note/delete/95337/non-english Del: in docs -- https://master.php.net/note/delete/95337/in+docs Del: other reasons-- https://master.php.net/note/delete/95337 Reject -- https://master.php.net/note/reject/95337 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#164376) next »