3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php function getGridStepForValue(float $c, int $minCountLines): float { $config = [50, 20, 15, 10]; $n = ceil($c); $length = \strlen((string)$n); while ($length) { foreach ($config as $singleDivisor) { $nDivisor = (float)str_pad((string)$singleDivisor, $length, '0'); if ($n - ($nDivisor * $minCountLines) > 0) { return $nDivisor; } } $length--; } return getGridStepForValue($c * 10, $minCountLines) / 10; } var_dump( getGridStepForValue(1, 4), getGridStepForValue(1, 5) );
based on 3o4q9
Output for hhvm-3.18.5 - 3.22.0, 7.0.0 - 7.3.0beta1
float(0.2) float(0.15)
Output for 5.6.0 - 5.6.30
Parse error: syntax error, unexpected ':', expecting '{' in /in/DY2VB on line 3
Process exited with code 255.