3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?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>"; if ($i % $count == $count - 1 || $i == $max - 1) $str .= "</ul>"; $i++; } echo $str;
Output for 4.3.0 - 5.6.28, hhvm-3.10.0 - 3.13.2, 7.0.0 - 7.1.0
<ul><li><a href='#'>0</a></li><li><a href='#'>1</a></li><li><a href='#'>2</a></li><li><a href='#'>3</a></li></ul><ul><li><a href='#'>4</a></li><li><a href='#'>5</a></li><li><a href='#'>6</a></li><li><a href='#'>7</a></li></ul><ul><li><a href='#'>8</a></li><li><a href='#'>9</a></li><li><a href='#'>10</a></li></ul>