<?php $num = [2.117647058, 0.002117647058]; foreach($num as $n){ if(substr($n,0,1) > 0){ echo round($n, 2) . "\n"; }else{ preg_match("/([0\.]+)(\d{1,2})/", $n, $m); echo $m[0] . "\n"; } }
You have javascript disabled. You will not be able to edit any code.