note 95337 deleted from function.in-array by bjori

From: Date: Fri, 01 Jan 2010 17:32:39 +0000
Subject: note 95337 deleted from function.in-array by bjori
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-164515@lists.php.net to get a copy of this message
Note Submitter: tim at gurka dot se ---- 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 ?>

« previous php.notes (#164515) next »