3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $valorNominal = '45750'; $posVirgula = ""; if(strpos($valorNominal, '.') > -1){ $posVirgula = substr( $valorNominal, strlen($valorNominal)-2, strlen($valorNominal) ); if(strpos($posVirgula, '.') > -1){ $posVirgula = str_replace(".", "", $posVirgula); $posVirgula .= '0'; } } else { $posVirgula = "00"; } $valorNominal = substr( $valorNominal, 0, strlen($valorNominal)-2 ); echo $valorNominal; die; $valorNominal = number_format((double)$valorNominal, 2, ',', '.'); $valorNominal = explode(',', $valorNominal); $valorNominal = $valorNominal[0].','.$posVirgula; echo $valorNominal;
based on ZpbiY
Output for 5.6.0 - 5.6.30, hhvm-3.15.4, 7.0.0 - 7.3.0alpha1
457