3v4l.org

run code in 300+ PHP versions simultaneously
<?php function koap2digit($koap){ $o = array('#[^.0-9]#','[.]{2,}'); $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 git.master, git.master_jit, rfc.property-hooks
Warning: preg_replace(): Unknown modifier '{' in /in/NhncR on line 5 Deprecated: explode(): Passing null to parameter #2 ($string) of type string is deprecated in /in/NhncR on line 6 Fatal error: Uncaught TypeError: Unsupported operand types: string * int in /in/NhncR:11 Stack trace: #0 /in/NhncR(25): koap2digit('12.21.1 \xD1\x87.1.1') #1 {main} thrown in /in/NhncR on line 11
Process exited with code 255.

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
39.4 ms | 401 KiB | 8 Q