andrisp Posted November 23, 2005 Report Share Posted November 23, 2005 (edited) ir piemeeram shaads kods: $columns = 3; foreach($array as $value) { echo '<tr>'."\n"; echo '<td>'.$value.'</td>'."\n"; for($x=1;$x<$columns;$x++) { echo '<td>'.next($array).'</td>'."\n"; } echo '</tr>'."\n"; } ideja taada, ka gribeejaas veertiibu drukaashanu tabulaas, izmantojot internal pointer paarvietoshanu, bet nezkaapeec sheit: foreach($array as $value) tiek ignoreets tas, ka ar next() tiek pointers pastumts uz priekshu.. kaapeec taa ? UPDATE: rekaa - http://lv.php.net/manual/en/function.next.php#41622 jaapameegjina pasham uzrakstiit savu foreach, kur tiek muuvots internat pointers. :) UPDATE2: uztaisiiju shaadu: while(false !== current($array)) { echo '<tr>'."\n"; for($x=0;$x<$columns;$x++) { if (false !== current($array)) { echo '<td>'.current($array).'</td>'."\n"; next($array); } else { echo '<td></td>'."\n"; } } echo '</tr>'."\n"; } izskataas, ka straada tiiri ok.. Edited November 23, 2005 by andrisp Link to comment Share on other sites More sharing options...
rpr Posted November 23, 2005 Report Share Posted November 23, 2005 labaak ir izmantot while(each()) {} Link to comment Share on other sites More sharing options...
Recommended Posts