3v4l.org

run code in 300+ PHP versions simultaneously
<?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.249, 5.244, 2.245, ); 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 PHP_EOL; }
Output for 4.3.10 - 4.3.11, 4.4.0 - 4.4.9, 5.0.2 - 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.24 - 5.5.35, 5.6.7 - 5.6.28, 7.0.0 - 7.0.20, 7.1.0 - 7.1.25, 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.18, 8.3.0 - 8.3.6
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.249 => 5,25 5.244 => 5,24 2.245 => 2,25
Output for 4.3.0 - 4.3.9, 5.0.0 - 5.0.1
1234 => 1.234 Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/tlbcp on line 44 PHP_EOL1234 => 1.234 Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/tlbcp on line 44 PHP_EOL1234.05 => 1.234,05 Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/tlbcp on line 44 PHP_EOL1234.005 => 1.234,01 Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/tlbcp on line 44 PHP_EOL1234.5 => 1.234,5 Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/tlbcp on line 44 PHP_EOL1234.5 => 1.234,5 Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/tlbcp on line 44 PHP_EOL1234.55 => 1.234,55 Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/tlbcp on line 44 PHP_EOL1234.505 => 1.234,51 Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/tlbcp on line 44 PHP_EOL1234.555 => 1.234,56 Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/tlbcp on line 44 PHP_EOL1234.5 => 1.234,5 Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/tlbcp on line 44 PHP_EOL1234.55 => 1.234,55 Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/tlbcp on line 44 PHP_EOL1234.555 => 1.234,56 Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/tlbcp on line 44 PHP_EOL1234.5555 => 1.234,56 Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/tlbcp on line 44 PHP_EOL3 => 3 Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/tlbcp on line 44 PHP_EOL3 => 3 Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/tlbcp on line 44 PHP_EOL3.05 => 3,05 Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/tlbcp on line 44 PHP_EOL3.5 => 3,5 Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/tlbcp on line 44 PHP_EOL3.5 => 3,5 Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/tlbcp on line 44 PHP_EOL3.55 => 3,55 Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/tlbcp on line 44 PHP_EOL3.55 => 3,55 Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/tlbcp on line 44 PHP_EOL3.555 => 3,56 Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/tlbcp on line 44 PHP_EOL3.555 => 3,56 Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/tlbcp on line 44 PHP_EOL3.5555 => 3,56 Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/tlbcp on line 44 PHP_EOL5.49 => 5,49 Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/tlbcp on line 44 PHP_EOL5.255 => 5,26 Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/tlbcp on line 44 PHP_EOL5.249 => 5,25 Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/tlbcp on line 44 PHP_EOL5.244 => 5,24 Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/tlbcp on line 44 PHP_EOL2.245 => 2,25 Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/tlbcp on line 44 PHP_EOL

preferences:
230.76 ms | 409 KiB | 328 Q