note 91188 deleted from control-structures.for by danbrown

From: Date: Fri, 29 May 2009 12:51:14 +0000
Subject: note 91188 deleted from control-structures.for by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-156143@lists.php.net to get a copy of this message
Note Submitter: wbeaumo1 at gmail dot com ---- RE: dkimbel13 There are a couple problems with your example. First, you're missing a couple closing parentheses in both the "for head" and the "for body". Second, the commas separating the for expressions should be semicolons. Otherwise, you're just resetting the array pointer, checking if the array pointer points to an element, and setting the array pointer to the next element ALL IN THE INITIALIZATION STEP. :) To correct: <?php for(reset($array);current($array);next($array)){ echo("Element ".key($array)." contains ".current($array)."<br/>"); } ?>

« previous php.notes (#156143) next »