- range: documentation ( source)
<?php
$value['title'] = range(0, 10);
$max = count($value['title']);
$i = 0;
$count = 4;
$str = '';
foreach ($value['title'] as $key2)
{
if ($i % $count == 0)
$str .= "<ul>";
$str .= "<li><a href='#'>$key2</a></li>" . PHP_EOL;
if ($i % $count == $count - 1 || $i == $max - 1)
$str .= "</ul>" . PHP_EOL;
$i++;
}
echo $str;