3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php function koap2digit($koap){ $o = array('#[^.0-9]#','[.]*'); $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 7.1.0
Warning: preg_replace(): Unknown modifier '*' in /in/L8XiY on line 5 Warning: A non-numeric value encountered in /in/L8XiY on line 11 0
Output for 5.2.5 - 7.0.14
Warning: preg_replace(): Unknown modifier '*' in /in/L8XiY on line 5 0
Output for 4.3.11 - 5.2.4
Warning: preg_replace(): Unknown modifier '*' in /in/L8XiY on line 5 1221010101
Output for 4.3.0 - 4.3.10
Warning: Unknown modifier '*' in /in/L8XiY on line 5 1221010101