3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $locales = array( 'en_US', 'en_GB', 'es_AR', 'es_ES', 'fr_FR', 'de_DE', 'he_IL', ); $styles = array( NumberFormatter::DECIMAL, NumberFormatter::CURRENCY, ); foreach ($locales as $locale) { foreach ($styles as $style) { echo "$locale -- $style\n"; $formatter = new NumberFormatter($locale, $style); var_dump($formatter->format(100)); var_dump($formatter->format(100.00)); var_dump($formatter->format('100')); var_dump($formatter->format('not a number')); var_dump($formatter->format(true)); var_dump($formatter->format(false)); var_dump($formatter->format(array())); var_dump($formatter->format(array(5))); } } $formatter = new NumberFormatter('en_GB', NumberFormatter::PATTERN_DECIMAL); var_dump($formatter->format('123456'));
Output for 7.0.14 - 7.1.0
en_US -- 1 string(3) "100" string(3) "100" string(3) "100" string(1) "0" string(1) "1" string(1) "0" string(1) "0" string(1) "1" en_US -- 2 string(7) "$100.00" string(7) "$100.00" string(7) "$100.00" string(5) "$0.00" string(5) "$1.00" string(5) "$0.00" string(5) "$0.00" string(5) "$1.00" en_GB -- 1 string(3) "100" string(3) "100" string(3) "100" string(1) "0" string(1) "1" string(1) "0" string(1) "0" string(1) "1" en_GB -- 2 string(8) "£100.00" string(8) "£100.00" string(8) "£100.00" string(6) "£0.00" string(6) "£1.00" string(6) "£0.00" string(6) "£0.00" string(6) "£1.00" es_AR -- 1 string(3) "100" string(3) "100" string(3) "100" string(1) "0" string(1) "1" string(1) "0" string(1) "0" string(1) "1" es_AR -- 2 string(9) "$ 100,00" string(9) "$ 100,00" string(9) "$ 100,00" string(7) "$ 0,00" string(7) "$ 1,00" string(7) "$ 0,00" string(7) "$ 0,00" string(7) "$ 1,00" es_ES -- 1 string(3) "100" string(3) "100" string(3) "100" string(1) "0" string(1) "1" string(1) "0" string(1) "0" string(1) "1" es_ES -- 2 string(11) "100,00 €" string(11) "100,00 €" string(11) "100,00 €" string(9) "0,00 €" string(9) "1,00 €" string(9) "0,00 €" string(9) "0,00 €" string(9) "1,00 €" fr_FR -- 1 string(3) "100" string(3) "100" string(3) "100" string(1) "0" string(1) "1" string(1) "0" string(1) "0" string(1) "1" fr_FR -- 2 string(11) "100,00 €" string(11) "100,00 €" string(11) "100,00 €" string(9) "0,00 €" string(9) "1,00 €" string(9) "0,00 €" string(9) "0,00 €" string(9) "1,00 €" de_DE -- 1 string(3) "100" string(3) "100" string(3) "100" string(1) "0" string(1) "1" string(1) "0" string(1) "0" string(1) "1" de_DE -- 2 string(11) "100,00 €" string(11) "100,00 €" string(11) "100,00 €" string(9) "0,00 €" string(9) "1,00 €" string(9) "0,00 €" string(9) "0,00 €" string(9) "1,00 €" he_IL -- 1 string(3) "100" string(3) "100" string(3) "100" string(1) "0" string(1) "1" string(1) "0" string(1) "0" string(1) "1" he_IL -- 2 string(14) "‏100.00 ₪" string(14) "‏100.00 ₪" string(14) "‏100.00 ₪" string(12) "‏0.00 ₪" string(12) "‏1.00 ₪" string(12) "‏0.00 ₪" string(12) "‏0.00 ₪" string(12) "‏1.00 ₪" string(6) "123456"
Output for 5.5.24 - 5.5.28, 5.5.31 - 5.5.33, 5.5.35 - 5.6.12, 5.6.16 - 5.6.19, 5.6.21 - 5.6.28, hhvm-3.12.0, 7.0.0 - 7.0.4, 7.0.6
en_US -- 1 string(3) "100" string(3) "100" string(3) "100" string(1) "0" string(1) "1" string(1) "0" string(1) "0" string(1) "1" en_US -- 2 string(7) "$100.00" string(7) "$100.00" string(7) "$100.00" string(5) "$0.00" string(5) "$1.00" string(5) "$0.00" string(5) "$0.00" string(5) "$1.00" en_GB -- 1 string(3) "100" string(3) "100" string(3) "100" string(1) "0" string(1) "1" string(1) "0" string(1) "0" string(1) "1" en_GB -- 2 string(8) "£100.00" string(8) "£100.00" string(8) "£100.00" string(6) "£0.00" string(6) "£1.00" string(6) "£0.00" string(6) "£0.00" string(6) "£1.00" es_AR -- 1 string(3) "100" string(3) "100" string(3) "100" string(1) "0" string(1) "1" string(1) "0" string(1) "0" string(1) "1" es_AR -- 2 string(9) "$ 100,00" string(9) "$ 100,00" string(9) "$ 100,00" string(7) "$ 0,00" string(7) "$ 1,00" string(7) "$ 0,00" string(7) "$ 0,00" string(7) "$ 1,00" es_ES -- 1 string(3) "100" string(3) "100" string(3) "100" string(1) "0" string(1) "1" string(1) "0" string(1) "0" string(1) "1" es_ES -- 2 string(11) "100,00 €" string(11) "100,00 €" string(11) "100,00 €" string(9) "0,00 €" string(9) "1,00 €" string(9) "0,00 €" string(9) "0,00 €" string(9) "1,00 €" fr_FR -- 1 string(3) "100" string(3) "100" string(3) "100" string(1) "0" string(1) "1" string(1) "0" string(1) "0" string(1) "1" fr_FR -- 2 string(11) "100,00 €" string(11) "100,00 €" string(11) "100,00 €" string(9) "0,00 €" string(9) "1,00 €" string(9) "0,00 €" string(9) "0,00 €" string(9) "1,00 €" de_DE -- 1 string(3) "100" string(3) "100" string(3) "100" string(1) "0" string(1) "1" string(1) "0" string(1) "0" string(1) "1" de_DE -- 2 string(11) "100,00 €" string(11) "100,00 €" string(11) "100,00 €" string(9) "0,00 €" string(9) "1,00 €" string(9) "0,00 €" string(9) "0,00 €" string(9) "1,00 €" he_IL -- 1 string(3) "100" string(3) "100" string(3) "100" string(1) "0" string(1) "1" string(1) "0" string(1) "0" string(1) "1" he_IL -- 2 string(11) "100.00 ₪" string(11) "100.00 ₪" string(11) "100.00 ₪" string(9) "0.00 ₪" string(9) "1.00 ₪" string(9) "0.00 ₪" string(9) "0.00 ₪" string(9) "1.00 ₪" string(6) "123456"
Output for 7.0.5
Fatal error: Uncaught Error: Class 'NumberFormatter' not found in /in/8Aoeb:14 Stack trace: #0 {main} thrown in /in/8Aoeb on line 14
Process exited with code 255.
Output for 5.4.34 - 5.4.45, hhvm-3.10.0
en_US -- 1 string(3) "100" string(3) "100" string(3) "100" string(1) "0" string(1) "1" string(1) "0" string(1) "0" string(1) "1" en_US -- 2 string(7) "$100.00" string(7) "$100.00" string(7) "$100.00" string(5) "$0.00" string(5) "$1.00" string(5) "$0.00" string(5) "$0.00" string(5) "$1.00" en_GB -- 1 string(3) "100" string(3) "100" string(3) "100" string(1) "0" string(1) "1" string(1) "0" string(1) "0" string(1) "1" en_GB -- 2 string(8) "£100.00" string(8) "£100.00" string(8) "£100.00" string(6) "£0.00" string(6) "£1.00" string(6) "£0.00" string(6) "£0.00" string(6) "£1.00" es_AR -- 1 string(3) "100" string(3) "100" string(3) "100" string(1) "0" string(1) "1" string(1) "0" string(1) "0" string(1) "1" es_AR -- 2 string(7) "$100,00" string(7) "$100,00" string(7) "$100,00" string(5) "$0,00" string(5) "$1,00" string(5) "$0,00" string(5) "$0,00" string(5) "$1,00" es_ES -- 1 string(3) "100" string(3) "100" string(3) "100" string(1) "0" string(1) "1" string(1) "0" string(1) "0" string(1) "1" es_ES -- 2 string(11) "100,00 €" string(11) "100,00 €" string(11) "100,00 €" string(9) "0,00 €" string(9) "1,00 €" string(9) "0,00 €" string(9) "0,00 €" string(9) "1,00 €" fr_FR -- 1 string(3) "100" string(3) "100" string(3) "100" string(1) "0" string(1) "1" string(1) "0" string(1) "0" string(1) "1" fr_FR -- 2 string(11) "100,00 €" string(11) "100,00 €" string(11) "100,00 €" string(9) "0,00 €" string(9) "1,00 €" string(9) "0,00 €" string(9) "0,00 €" string(9) "1,00 €" de_DE -- 1 string(3) "100" string(3) "100" string(3) "100" string(1) "0" string(1) "1" string(1) "0" string(1) "0" string(1) "1" de_DE -- 2 string(11) "100,00 €" string(11) "100,00 €" string(11) "100,00 €" string(9) "0,00 €" string(9) "1,00 €" string(9) "0,00 €" string(9) "0,00 €" string(9) "1,00 €" he_IL -- 1 string(3) "100" string(3) "100" string(3) "100" string(1) "0" string(1) "1" string(1) "0" string(1) "0" string(1) "1" he_IL -- 2 string(11) "100.00 ₪" string(11) "100.00 ₪" string(11) "100.00 ₪" string(9) "0.00 ₪" string(9) "1.00 ₪" string(9) "0.00 ₪" string(9) "0.00 ₪" string(9) "1.00 ₪" string(6) "123456"
Output for 5.0.0 - 5.4.32, 5.5.29 - 5.5.30, 5.5.34, 5.6.13 - 5.6.15, 5.6.20
Fatal error: Class 'NumberFormatter' not found in /in/8Aoeb on line 14
Process exited with code 255.
Output for 4.4.2 - 4.4.9
Parse error: syntax error, unexpected ',', expecting '(' in /in/8Aoeb on line 14
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.4.1
Parse error: parse error, unexpected ',', expecting '(' in /in/8Aoeb on line 14
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error, expecting `'('' in /in/8Aoeb on line 14
Process exited with code 255.