note 10975 deleted from function.key by irc-html

From: Date: Sat, 19 Jan 2002 21:55:46 +0000
Subject: note 10975 deleted from function.key by irc-html
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-25501@lists.php.net to get a copy of this message
[Editor's Note: key() returns NULL when attempting to return an unset key. Use the strict comparison operator to differentiate between NULL and 0 i.e. while ( NULL !== ($key = key ($myArray))) { // do some job } --zak@php.net] Sometimes, the first key of an associative array is numeric zero(or null). Then you can't use key as the following because the very first cycle of the loop cannot be accomplished. while ( $key = key( $myArray ) ) { // do some job } So be careful...

« previous php.notes (#25501) next »