3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $separator = 'dot'; $number = '1,233,332.34'; $number2 = '1.233.332,34'; $thousand_separator = ','; if ($separator != 'comma') { $thousand_separator = '.'; } // Remove the thousand separator $number = str_replace($thousand_separator, '', $number); $number2 = str_replace($thousand_separator, '', $number2); echo '$number: ' . number_format($number, 2, ',','.') . PHP_EOL; echo '$number2: ' . number_format($number2, 2, ',','.') . PHP_EOL;
Output for 5.3.0 - 7.1.0
Notice: A non well formed numeric value encountered in /in/JCMdH on line 17 $number: 1,00 Notice: A non well formed numeric value encountered in /in/JCMdH on line 18 $number2: 1.233.332,00
Output for 4.3.10 - 4.4.9, 5.0.2 - 5.2.17
$number: 1,00 $number2: 1.233.332,00
Output for 4.3.0 - 4.3.9, 5.0.0 - 5.0.1
Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/JCMdH on line 17 $number: 1,00PHP_EOL Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/JCMdH on line 18 $number2: 1.233.332,00PHP_EOL