3v4l.org

run code in 300+ PHP versions simultaneously
<?php $arr = [0.12345,0.012345,0.0001239,0.0001209]; Foreach($arr as $val){ Preg_match("/([0\.]+)([0-9]+)/", $val, $match); Echo $match[1]. Substr(round("0.".$match[2],3),2,3)."\n"; }

preferences:
35.94 ms | 406 KiB | 5 Q