note 91188 added to control-structures.for

From: Date: Fri, 29 May 2009 08:32:36 +0000
Subject: note 91188 added to control-structures.for
Groups: php.notes 
Request: Send a blank email to php-notes+get-156138@lists.php.net to get a copy of this message
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/>"); } ?> ---- Server IP: 69.147.83.197 Probable Submitter: 75.82.195.12 ---- Manual Page -- http://www.php.net/manual/en/control-structures.for.php Edit -- https://master.php.net/note/edit/91188 Del: integrated -- https://master.php.net/note/delete/91188/integrated Del: useless -- https://master.php.net/note/delete/91188/useless Del: bad code -- https://master.php.net/note/delete/91188/bad+code Del: spam -- https://master.php.net/note/delete/91188/spam Del: non-english -- https://master.php.net/note/delete/91188/non-english Del: in docs -- https://master.php.net/note/delete/91188/in+docs Del: other reasons-- https://master.php.net/note/delete/91188 Reject -- https://master.php.net/note/reject/91188 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#156138) next »