note 110573 added to control-structures.for

From: Date: Thu, 08 Nov 2012 16:34:33 +0000
Subject: note 110573 added to control-structures.for
Groups: php.notes 
Request: Send a blank email to php-notes+get-191811@lists.php.net to get a copy of this message
Note, that, because the first line is executed everytime, it is not only slow to put a function there, it can also lead to problems like: <?php $array = array(0 => "a", 1 => "b", 2 => "c", 3 => "d"); for($i = 0; $i < count($array); $i++){ echo $array[$i]; unset($array[$i]); } ?> This will only output the half of the elements, because the array is becoming shorter everytime the for-expression counts it. ---- Server IP: 69.147.83.199 Probable Submitter: 146.52.55.72 ---- Manual Page -- http://www.php.net/manual/en/control-structures.for.php Edit -- https://master.php.net/note/edit/110573 Del: integrated -- https://master.php.net/note/delete/110573/integrated Del: useless -- https://master.php.net/note/delete/110573/useless Del: bad code -- https://master.php.net/note/delete/110573/bad+code Del: spam -- https://master.php.net/note/delete/110573/spam Del: non-english -- https://master.php.net/note/delete/110573/non-english Del: in docs -- https://master.php.net/note/delete/110573/in+docs Del: other reasons-- https://master.php.net/note/delete/110573 Reject -- https://master.php.net/note/reject/110573 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#191811) next »