note 45701 deleted from function.array-search by tomsommer

From: Date: Wed, 15 Sep 2004 16:36:27 +0000
Subject: note 45701 deleted from function.array-search by tomsommer
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-76750@lists.php.net to get a copy of this message
Note Submitter: geoff at hoffmans dot net ---- It's not immediately obvious from the docs, so I did my own test to be sure. If you search in a non-associative array, array_search does indeed return the zero-based numeric index of your search value. If not found, returns false. <?php // test to see if array_search works on non-associative arrays $array = array("a","b","c","d","e","g","f"); $pos = array_search("g", $array); echo $pos; // echoes 5 $pos2 = array_search("N", $array); if( $pos2 === NULL ) { echo "null" ; } if( $pos2 === false ) { echo "false" ; } // echoes false ?>

« previous php.notes (#76750) next »