3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php function tofloat($num) { $dotPos = strrpos($num, '.'); $commaPos = strrpos($num, ','); $sep = (($dotPos > $commaPos) && $dotPos) ? $dotPos : ((($commaPos > $dotPos) && $commaPos) ? $commaPos : false); if (!$sep) { return floatval(preg_replace("/[^0-9]/", "", $num)); } return floatval( preg_replace("/[^0-9]/", "", substr($num, 0, $sep)) . '.' . preg_replace("/[^0-9]/", "", substr($num, $sep+1, strlen($num))) ); } echo tofloat('2,32') ;
based on 77ed6
Output for 4.3.0 - 5.6.28, hhvm-3.12.0, 7.0.0 - 7.1.0
2.32
Output for hhvm-3.10.0

Process exited with code 153.