3v4l.org

run code in 300+ PHP versions simultaneously
<?php $total_pages = 10; $current_page = 1; $boundaries = 1; $around = 1; $startPages = range(1, max($boundaries, 1)); $endPages = range($total_pages - max(($boundaries - 1), 0), $total_pages); $aroundLeft = range(max($current_page - $around, 1), $current_page); $aroundRight = range($current_page, min($current_page + $around, $total_pages)); $result = array_values(array_unique(array_merge($startPages, $aroundLeft, $aroundRight, $endPages))); $final = array(); for($i = 0; $i<count($result) -1;$i++) { array_push($final, $result[$i]); if($result[$i+1] - $result[$i] > 1) { array_push($final, "..."); } } array_push($final, $result[count($result) - 1]); foreach($final as $item) { echo $item . " "; } ?>
Output for git.master, git.master_jit, rfc.property-hooks
1 2 ... 10

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
62.8 ms | 401 KiB | 8 Q