3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php function koap2digit($koap){ $o = array('#[^.0-9]#','#[.]{2,}#'); $n = array('','.'); $digits = preg_replace($o, $n, $koap); $ar = explode('.', $digits); $r = 1000000; $num = 0; foreach($ar as $k => $v) { if($k == 0)$num = $v*100; elseif($k == 1) { $num = ($num+$v)*$r; } else { $r = $r/100; $num += $v*$r; } } return $num; } echo koap2digit('12.21.1 ч.1.1');
Output for 4.3.0 - 7.1.0
1221010101