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 $digit; } echo koap2digit('12.21.1 ч.1.1');
Output for 7.1.0
Warning: preg_replace(): Delimiter must not be alphanumeric or backslash in /in/GEImn on line 5 Warning: A non-numeric value encountered in /in/GEImn on line 14 Notice: Undefined variable: digit in /in/GEImn on line 21
Output for 5.0.4 - 5.6.28, 7.0.0 - 7.0.14
Warning: preg_replace(): Delimiter must not be alphanumeric or backslash in /in/GEImn on line 5 Notice: Undefined variable: digit in /in/GEImn on line 21
Output for hhvm-3.12.0 - 3.13.2
Warning: Delimiter must not be alphanumeric or backslash in /in/GEImn on line 5 Warning: explode() expects parameter 2 to be string, null given in /in/GEImn on line 6 Warning: Invalid argument supplied for foreach() in /in/GEImn on line 20 Notice: Undefined variable: digit in /in/GEImn on line 21
Output for hhvm-3.10.0
Warning: Delimiter must not be alphanumeric or backslash in /in/GEImn on line 5 Notice: Undefined variable: digit in /in/GEImn on line 21
Output for 4.3.11 - 5.0.3
Warning: preg_replace(): Delimiter must not be alphanumeric or backslash in /in/GEImn on line 5 Notice: Undefined variable: digit in /in/GEImn on line 21
Output for 4.3.0 - 4.3.10
Warning: Delimiter must not be alphanumeric or backslash in /in/GEImn on line 5 Notice: Undefined variable: digit in /in/GEImn on line 21