3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $numbers = array( 1234, 1234.0, 1234.05, 1234.005, 1234.5, 1234.50, 1234.55, 1234.505, 1234.555, 1234.5000, 1234.5500, 1234.5550, 1234.5555, 3, 3.0, 3.05, 3.5, 3.50, 3.55, 3.550, 3.555, 3.5550, 3.5555, 5.49, 5.255, 5.252, 5.249, 5.244, 2.245, ); var_dump($numbers); echo PHP_EOL . PHP_EOL; function format_to_komma_ruggit($number) { $number = round($number, 2); $number = number_format($number, strlen(substr(strrchr($number, "."), 1)), ',', '.'); return $number; } foreach ($numbers as $number) { echo $number . ' => ' . format_to_komma_ruggit($number); echo "\r\n"; }
Output for 4.3.10 - 4.4.9, 5.0.2 - 5.6.28, hhvm-3.12.0, 7.0.0 - 7.1.0
array(29) { [0]=> int(1234) [1]=> float(1234) [2]=> float(1234.05) [3]=> float(1234.005) [4]=> float(1234.5) [5]=> float(1234.5) [6]=> float(1234.55) [7]=> float(1234.505) [8]=> float(1234.555) [9]=> float(1234.5) [10]=> float(1234.55) [11]=> float(1234.555) [12]=> float(1234.5555) [13]=> int(3) [14]=> float(3) [15]=> float(3.05) [16]=> float(3.5) [17]=> float(3.5) [18]=> float(3.55) [19]=> float(3.55) [20]=> float(3.555) [21]=> float(3.555) [22]=> float(3.5555) [23]=> float(5.49) [24]=> float(5.255) [25]=> float(5.252) [26]=> float(5.249) [27]=> float(5.244) [28]=> float(2.245) } 1234 => 1.234 1234 => 1.234 1234.05 => 1.234,05 1234.005 => 1.234,01 1234.5 => 1.234,5 1234.5 => 1.234,5 1234.55 => 1.234,55 1234.505 => 1.234,51 1234.555 => 1.234,56 1234.5 => 1.234,5 1234.55 => 1.234,55 1234.555 => 1.234,56 1234.5555 => 1.234,56 3 => 3 3 => 3 3.05 => 3,05 3.5 => 3,5 3.5 => 3,5 3.55 => 3,55 3.55 => 3,55 3.555 => 3,56 3.555 => 3,56 3.5555 => 3,56 5.49 => 5,49 5.255 => 5,26 5.252 => 5,25 5.249 => 5,25 5.244 => 5,24 2.245 => 2,25
Output for hhvm-3.10.0

Process exited with code 153.
Output for 4.3.0 - 4.3.9, 5.0.0 - 5.0.1
array(29) { [0]=> int(1234) [1]=> float(1234) [2]=> float(1234.05) [3]=> float(1234.005) [4]=> float(1234.5) [5]=> float(1234.5) [6]=> float(1234.55) [7]=> float(1234.505) [8]=> float(1234.555) [9]=> float(1234.5) [10]=> float(1234.55) [11]=> float(1234.555) [12]=> float(1234.5555) [13]=> int(3) [14]=> float(3) [15]=> float(3.05) [16]=> float(3.5) [17]=> float(3.5) [18]=> float(3.55) [19]=> float(3.55) [20]=> float(3.555) [21]=> float(3.555) [22]=> float(3.5555) [23]=> float(5.49) [24]=> float(5.255) [25]=> float(5.252) [26]=> float(5.249) [27]=> float(5.244) [28]=> float(2.245) } Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/Bqb86 on line 35 Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/Bqb86 on line 35 PHP_EOLPHP_EOL1234 => 1.234 1234 => 1.234 1234.05 => 1.234,05 1234.005 => 1.234,01 1234.5 => 1.234,5 1234.5 => 1.234,5 1234.55 => 1.234,55 1234.505 => 1.234,51 1234.555 => 1.234,56 1234.5 => 1.234,5 1234.55 => 1.234,55 1234.555 => 1.234,56 1234.5555 => 1.234,56 3 => 3 3 => 3 3.05 => 3,05 3.5 => 3,5 3.5 => 3,5 3.55 => 3,55 3.55 => 3,55 3.555 => 3,56 3.555 => 3,56 3.5555 => 3,56 5.49 => 5,49 5.255 => 5,26 5.252 => 5,25 5.249 => 5,25 5.244 => 5,24 2.245 => 2,25