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; 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/YZJaU on line 5 Notice: Undefined variable: num in /in/YZJaU on line 13 Warning: A non-numeric value encountered in /in/YZJaU on line 13 Notice: Use of undefined constant r - assumed 'r' in /in/YZJaU on line 13 Warning: A non-numeric value encountered in /in/YZJaU on line 13 Notice: Undefined variable: digit in /in/YZJaU on line 20
Output for 5.3.28 - 5.3.29, 5.4.20 - 5.6.28, 7.0.0 - 7.0.14
Warning: preg_replace(): Delimiter must not be alphanumeric or backslash in /in/YZJaU on line 5 Notice: Undefined variable: num in /in/YZJaU on line 13 Notice: Use of undefined constant r - assumed 'r' in /in/YZJaU on line 13 Notice: Undefined variable: digit in /in/YZJaU on line 20
Output for hhvm-3.10.0 - 3.12.0
Warning: Delimiter must not be alphanumeric or backslash in /in/YZJaU on line 5 Notice: Undefined variable: num in /in/YZJaU on line 13 Notice: Use of undefined constant r - assumed 'r' in /in/YZJaU on line 13 Notice: Undefined variable: digit in /in/YZJaU on line 20
Output for 5.2.5 - 5.3.27, 5.4.0 - 5.4.19
Warning: preg_replace(): Delimiter must not be alphanumeric or backslash in /in/0hHWo on line 5 Notice: Undefined variable: num in /in/0hHWo on line 13 Notice: Use of undefined constant r - assumed 'r' in /in/0hHWo on line 13 Notice: Undefined variable: digit in /in/0hHWo on line 20
Output for 5.0.4 - 5.2.4
Warning: preg_replace(): Delimiter must not be alphanumeric or backslash in /in/0hHWo on line 5 Notice: Undefined variable: num in /in/0hHWo on line 13 Notice: Use of undefined constant r - assumed 'r' in /in/0hHWo on line 13 Notice: Use of undefined constant r - assumed 'r' in /in/0hHWo on line 13 Notice: Use of undefined constant r - assumed 'r' in /in/0hHWo on line 13 Notice: Use of undefined constant r - assumed 'r' in /in/0hHWo on line 13 Notice: Use of undefined constant r - assumed 'r' in /in/0hHWo on line 13 Notice: Undefined variable: digit in /in/0hHWo on line 20
Output for 4.3.11 - 5.0.3
Warning: preg_replace(): Delimiter must not be alphanumeric or backslash in /in/0hHWo on line 5 Notice: Undefined variable: num in /in/0hHWo on line 13 Notice: Use of undefined constant r - assumed 'r' in /in/0hHWo on line 13 Notice: Use of undefined constant r - assumed 'r' in /in/0hHWo on line 13 Notice: Use of undefined constant r - assumed 'r' in /in/0hHWo on line 13 Notice: Use of undefined constant r - assumed 'r' in /in/0hHWo on line 13 Notice: Use of undefined constant r - assumed 'r' in /in/0hHWo on line 13 Notice: Undefined variable: digit in /in/0hHWo on line 20
Output for 4.3.1 - 4.3.10
Warning: Delimiter must not be alphanumeric or backslash in /in/0hHWo on line 5 Notice: Undefined variable: num in /in/0hHWo on line 13 Notice: Use of undefined constant r - assumed 'r' in /in/0hHWo on line 13 Notice: Use of undefined constant r - assumed 'r' in /in/0hHWo on line 13 Notice: Use of undefined constant r - assumed 'r' in /in/0hHWo on line 13 Notice: Use of undefined constant r - assumed 'r' in /in/0hHWo on line 13 Notice: Use of undefined constant r - assumed 'r' in /in/0hHWo on line 13 Notice: Undefined variable: digit in /in/0hHWo on line 20
Output for 4.3.0
Warning: Delimiter must not be alphanumeric or backslash in /in/YZJaU on line 5 Notice: Undefined variable: num in /in/YZJaU on line 13 Notice: Use of undefined constant r - assumed 'r' in /in/YZJaU on line 13 Notice: Use of undefined constant r - assumed 'r' in /in/YZJaU on line 13 Notice: Use of undefined constant r - assumed 'r' in /in/YZJaU on line 13 Notice: Use of undefined constant r - assumed 'r' in /in/YZJaU on line 13 Notice: Use of undefined constant r - assumed 'r' in /in/YZJaU on line 13 Notice: Undefined variable: digit in /in/YZJaU on line 20