3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $pages->total_pages = 30; $pages->current = 15; $displayPageFrom = (($pages->current <= 10) ? 1 : (floor($pages->current / 10) * 10)); $displayGroupCount = ((floor($pages->total_pages / 10)) + (($pages->total_pages % 10) ? 1 : 0 )); for ($index = 1; $index < $displayGroupCount; $index++) { $displayGroupPageFrom = (($index == 1) ? 1 : ($index * 10)); $displayGroupPageTo = (($index == 1) ? 10 : ($displayGroupPageFrom + 10)); $displayGroupPageTo = (($displayGroupPageTo > $pages->total_pages) ? ($displayGroupPageFrom + (10 - ($displayGroupPageTo - $pages->total_pages))) : $displayGroupPageTo); $output[] = '<li' . (($displayGroupPageFrom == $displayPageFrom) ? ' class="active"' : '') . '>' . $displayGroupPageFrom . ' - ' . $displayGroupPageTo . '</li>'; } var_dump($output);
based on hJgUd
Output for 5.6.0 - 5.6.30, hhvm-3.15.4, 7.0.0 - 7.3.0alpha1
Warning: Creating default object from empty value in /in/1H6Ze on line 2 array(2) { [0]=> string(15) "<li>1 - 10</li>" [1]=> string(16) "<li>20 - 30</li>" }