3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $pointsNo = 190; // e.g count($coordsX) == 190; $maxPolyPoints = 120; $idxRatio = round($pointsNo/$maxPolyPoints); $idx = 0; $i = 0; while ($idx<$pointsNo){ //$newX[$i] = $coordsX[$idx]; //$newY[$i] = $coordsY[$idx]; $idx += $idxRatio; $i++; } echo "existing: ".$i; echo "<br>"; $idxRatio = $pointsNo/$maxPolyPoints; $idx = 0; $i = 0; while (ceil($idx)<$pointsNo){ //$newX[$i] = $coordsX[round($idx)]; //$newY[$i] = $coordsY[round($idx)]; $idx += $idxRatio; $i++; } echo "improved: ".$i;
Output for 4.3.0 - 5.6.28, hhvm-3.10.0 - 3.12.0, 7.0.0 - 7.1.0
existing: 95<br>improved: 120