note 82007 added to control-structures.for

From: Date: Mon, 24 Mar 2008 13:05:18 +0000
Subject: note 82007 added to control-structures.for
Groups: php.notes 
Request: Send a blank email to php-notes+get-137453@lists.php.net to get a copy of this message
Nested For Loop with the same iterator as the parent. (Well formatted so the resulting code is clean when executed). Useful for outputting a data array into a table, ie. images. <?php //Dummy data $data = array(73,74,75,76,78,79,80,81,82,83,84,85,86,87); //Our 'stepping' variable $g = 0; //Our rowcount $rowcount = 0; echo "<table cellspacing='0'>\r"; for ($i=0; $i<count($data); ) { $rowcount++; echo " <tr>\r"; //New row $g = $i + 3; //Set our nested limit for( ; $i<$g; $i++) { //nested for loop if (!isset($data[$i])) { //Allow us to break on incomplete rows break; } echo " <td style='border: 1px #000 solid;'>\r"; //Out put a cell echo " <p>Row $rowcount <br/> Cell: $i <br/> Data: $data[$i]</p>\r"; echo " </td>\r"; } echo " </tr> \r"; //End New Row } echo "</table>\r";?> ---- Server IP: 117.104.160.194 Probable Submitter: 203.59.12.89 ---- Manual Page -- http://www.php.net/manual/en/control-structures.for.php Edit -- https://master.php.net/note/edit/82007 Del: integrated -- https://master.php.net/note/delete/82007/integrated Del: useless -- https://master.php.net/note/delete/82007/useless Del: bad code -- https://master.php.net/note/delete/82007/bad+code Del: spam -- https://master.php.net/note/delete/82007/spam Del: non-english -- https://master.php.net/note/delete/82007/non-english Del: in docs -- https://master.php.net/note/delete/82007/in+docs Del: other reasons-- https://master.php.net/note/delete/82007 Reject -- https://master.php.net/note/reject/82007 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#137453) next »