3v4l.org

run code in 200+ 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 - 7.3.0rc4
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 - 7.0.20
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.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