3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $max_parcelas = 10; $arr = []; $range = range(1,$max_parcelas); $base = 2000; $cheio = 2900; $dif = $cheio - $base; foreach($range as $x) { $quo = log($x, $max_parcelas); $val = $base + ($quo * $dif); $arr[$x] = ['quo' => $quo, 'valor' => $val]; } echo '## Parcelamento Logarítimico ##'; print_r($arr); unset($arr); foreach($range as $x) { $quo = $x/$max_parcelas; $val = $base + ($quo * $dif); $arr[$x] = ['quo' => $quo, 'valor' => $val]; } echo '## Parcelamento Linear ##'; print_r($arr);
Output for 5.4.0 - 7.2.0
## Parcelamento Logarítimico ##Array ( [1] => Array ( [quo] => 0 [valor] => 2000 ) [2] => Array ( [quo] => 0.30102999566398 [valor] => 2270.9269960976 ) [3] => Array ( [quo] => 0.47712125471966 [valor] => 2429.4091292477 ) [4] => Array ( [quo] => 0.60205999132796 [valor] => 2541.8539921952 ) [5] => Array ( [quo] => 0.69897000433602 [valor] => 2629.0730039024 ) [6] => Array ( [quo] => 0.77815125038364 [valor] => 2700.3361253453 ) [7] => Array ( [quo] => 0.84509804001426 [valor] => 2760.5882360128 ) [8] => Array ( [quo] => 0.90308998699194 [valor] => 2812.7809882927 ) [9] => Array ( [quo] => 0.95424250943932 [valor] => 2858.8182584954 ) [10] => Array ( [quo] => 1 [valor] => 2900 ) ) ## Parcelamento Linear ##Array ( [1] => Array ( [quo] => 0.1 [valor] => 2090 ) [2] => Array ( [quo] => 0.2 [valor] => 2180 ) [3] => Array ( [quo] => 0.3 [valor] => 2270 ) [4] => Array ( [quo] => 0.4 [valor] => 2360 ) [5] => Array ( [quo] => 0.5 [valor] => 2450 ) [6] => Array ( [quo] => 0.6 [valor] => 2540 ) [7] => Array ( [quo] => 0.7 [valor] => 2630 ) [8] => Array ( [quo] => 0.8 [valor] => 2720 ) [9] => Array ( [quo] => 0.9 [valor] => 2810 ) [10] => Array ( [quo] => 1 [valor] => 2900 ) )
Output for 4.4.2 - 4.4.9, 5.1.0 - 5.3.29
Parse error: syntax error, unexpected '[' in /in/BJfo5 on line 4
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.4.1, 5.0.0 - 5.0.5
Parse error: parse error, unexpected '[' in /in/BJfo5 on line 4
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error in /in/BJfo5 on line 4
Process exited with code 255.