- next: documentation ( source)
- current: documentation ( source)
<?php
//$arr = array(1,2,3,4,5,6,7,8,9,0);
$arr = array(1,2,3,4,5,6,7,8);
$i = 0;
$s = '';
while ($item = current($arr)) {
echo $i."\n";
$s .= "<a href='#'>$item</a>\n";
if ($i % 4 == 0) {
$s .= "<li>$s</li>\n";
echo $s;
$s = '';
}
$i++;
next($arr);
}
echo $i;
$s .= ($i%4) ? "</li>\n" : '';
echo $s;