3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php function per2num($per){ return (float)$per/100; } $tests = array("2%","25%","2.01%","25.00%"); foreach($tests as $test) echo $test,": ",per2num($test),"\r\n";
based on rnaKC
Output for 4.3.0 - 5.6.21, hhvm-3.10.0 - 3.12.0, 7.0.0 - 7.1.0
2%: 0.02 25%: 0.25 2.01%: 0.0201 25.00%: 0.25