3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php function koap2digit($koap){ $o = array('#[^\d.]#','\.\.'); $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 { $num += $v*($r/100); } } return $num; } echo koap2digit('12.21.1 ч.1.1');
Output for 7.1.0
Warning: preg_replace(): Delimiter must not be alphanumeric or backslash in /in/Bnius on line 5 Warning: A non-numeric value encountered in /in/Bnius on line 11 0
Output for 5.2.5 - 5.6.28, 7.0.0 - 7.0.14
Warning: preg_replace(): Delimiter must not be alphanumeric or backslash in /in/Bnius on line 5 0
Output for hhvm-3.12.0
Warning: Delimiter must not be alphanumeric or backslash in /in/Bnius on line 5 Warning: explode() expects parameter 2 to be string, null given in /in/Bnius on line 6 Warning: Invalid argument supplied for foreach() in /in/Bnius on line 20 0
Output for hhvm-3.10.0
Warning: Delimiter must not be alphanumeric or backslash in /in/Bnius on line 5 0
Output for 4.3.11 - 5.2.4
Warning: preg_replace(): Delimiter must not be alphanumeric or backslash in /in/Bnius on line 5 1221030000
Output for 4.3.0 - 4.3.10
Warning: Delimiter must not be alphanumeric or backslash in /in/Bnius on line 5 1221030000