note 36488 deleted from function.next by ali

From: Date: Sat, 11 Oct 2003 11:39:20 +0000
Subject: note 36488 deleted from function.next by ali
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-58241@lists.php.net to get a copy of this message
Note Submitter: m.schot@sockit.nl ---- When using next($var) on an array containing an empty string or 0, next will stop at that item. $var=array("a"=>"aaaa","b"=>"","c"=>"cccc"); reset($var); do{ echo current($var)."\n"; }while(next($var)); this should print: aaaa cccc but it prints: aaaa The null value is not printed and the loop is stopped. When you loop over it with: for($counter=0;$counter<count($var);$counter++){ echo current($var)."\n"; next($var); } The output will be as it should be so my guess is that next returns false on null values. Foreach does it correctly as well.

« previous php.notes (#58241) next »