- range: documentation ( source)
- sprintf: documentation ( source)
<?php
$images = range(1, 24);
foreach ($images as $i => $image) {
if ($i % 6 === 0) {
echo "-- row-open";
}
echo sprintf(" [ %d ] ", $image);
if ($i % 6 === 0) {
echo "-- row-close\n";
}
}