3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $formattedMoney = '-$1000'; $parser = new \NumberFormatter('en_US', \NumberFormatter::CURRENCY); $parser->setAttribute(\NumberFormatter::FRACTION_DIGITS, 2); $parser->setAttribute(\NumberFormatter::NEGATIVE_PREFIX, '-'); $decimal = $parser->parseCurrency($formattedMoney, $currency); var_dump($decimal); var_dump($currency);
based on S7nng
Output for 5.4.12 - 5.4.45, 5.6.0 - 7.3.0
float(-1000) string(3) "USD"
Output for 5.3.22 - 5.3.29, 5.5.0 - 5.5.38
Fatal error: Class 'NumberFormatter' not found in /in/Mu50i on line 5
Process exited with code 255.