3v4l.org

run code in 300+ PHP versions simultaneously
<?php /* http://3v4l.org/DCTnA */ /* < [1] 2 3 ... 22 23 > < 1 [2] 3 ... 22 23 > < 1 2 [3] 4 ... 22 23 > < 1 2 3 [4] 5 ... 22 23 > < 1 2 ... 4 [5] 6 ... 22 23 > < 1 2 ... 5 [6] 7 ... 22 23 > ... < 1 2 ... 18 [19] 20 ... 22 23 > < 1 2 ... 19 [20] 21 22 23 > < 1 2 ... 20 [21] 22 23 > < 1 2 ... 21 [22] 23 > < 1 2 ... 22 [23] > */ for ($ss = -1; $ss<10; ++$ss){ $currentpageid = $nmstart = $ss; echo "\n"; echo "\n"; echo "\n"; echo '-----------------'; echo "\n"; var_dump($ss); echo "\n"; $currentpageid = $nmstart = $ss; $nrtotal = 23; $nrposts = 1; $pages = ''; $ssPagingStartCount = 2; $ssPagingCurrentCount = 4; $ssPagingEndCount = 2; $totalpages = ceil($nrtotal / $nrposts); if ($totalpages > 1 ){ /* for ($x = 0; $x < $totalpages; ++$x) { $inc = $x * $nrposts; $display = $x + 1; if($inc != $nmstart) { $pages .= "\n<a class=\"nl_page\" href='" . "nmstart=$inc'>".$display."</a>"; } else { $pages .= "\n<span class=\"nl_page nl_page__currentpage\">".$display."</span>"; } } */ //$ssPagingCurrentCountRight = max($ssPagingStartCount, ($currentpageid + (int)($ssPagingCurrentCount/2))); $ssPagingCurrentCountFrom = $currentpageid - (int)(($ssPagingCurrentCount-1)/2) - 1; if ( $ssPagingCurrentCountFrom < 0 ) $ssPagingCurrentCountFrom = 0; $ssPagingCurrentCountTo = $currentpageid + (int)(($ssPagingCurrentCount-1)/2) + 1; if ( $ssPagingCurrentCountTo > $totalpages ) $ssPagingCurrentCountTo = $totalpages; if ( ($currentpageid >= 0) && ($currentpageid <= ($ssPagingStartCount + (int)(($ssPagingCurrentCount-1)/2))) ) { for ($x = 0; $x < $ssPagingCurrentCountTo; ++$x) { $inc = $x * $nrposts; $display = $x + 1; if ($inc != $nmstart) { $pages .= "\n<a class=\"nl_page\" href='" . "nmstart=$inc'>".$display."</a>"; } else { $pages .= "\n<span class=\"nl_page nl_page__currentpage\">".$display."</span>"; } } } } var_dump($pages); } ?>
Output for 4.3.0 - 4.3.11, 4.4.0 - 4.4.9, 5.0.0 - 5.0.5, 5.1.0 - 5.1.6, 5.2.0 - 5.2.17, 5.3.0 - 5.3.29, 5.4.0 - 5.4.45, 5.5.0 - 5.5.38, 5.6.0 - 5.6.40, 7.0.0 - 7.0.33, 7.1.0 - 7.1.33, 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.19, 8.3.0 - 8.3.7
----------------- int(-1) string(0) "" ----------------- int(0) string(94) " <span class="nl_page nl_page__currentpage">1</span> <a class="nl_page" href='nmstart=1'>2</a>" ----------------- int(1) string(136) " <a class="nl_page" href='nmstart=0'>1</a> <span class="nl_page nl_page__currentpage">2</span> <a class="nl_page" href='nmstart=2'>3</a>" ----------------- int(2) string(178) " <a class="nl_page" href='nmstart=0'>1</a> <a class="nl_page" href='nmstart=1'>2</a> <span class="nl_page nl_page__currentpage">3</span> <a class="nl_page" href='nmstart=3'>4</a>" ----------------- int(3) string(220) " <a class="nl_page" href='nmstart=0'>1</a> <a class="nl_page" href='nmstart=1'>2</a> <a class="nl_page" href='nmstart=2'>3</a> <span class="nl_page nl_page__currentpage">4</span> <a class="nl_page" href='nmstart=4'>5</a>" ----------------- int(4) string(0) "" ----------------- int(5) string(0) "" ----------------- int(6) string(0) "" ----------------- int(7) string(0) "" ----------------- int(8) string(0) "" ----------------- int(9) string(0) ""

preferences:
256.11 ms | 408 KiB | 461 Q