3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php function edit_distance_ond($str1 ,$str2){ $array = array(); $x = 0; $y = 0; $offset = count($str1); $array[$offset + 1] = 0; for($D = 0; $D <= count($str1) + count($str2); $D++){ for($k = -$D; $k <= $D; $k += 2){ if($k == -$D || $k != $D && $array[$k-1+$offset] < $array[$k+1+$offset]) $x = $array[$k+1+$offset]; else $x = $array[$k-1+$offset] + 1; $y = $x - $k; while($x < count($str1) && $y < count($str2) && $str1[$x] == $str2[$y]){ $x++; $y++; } $array[$k+$offset] = $x; if($x >= count($str1) && $y >= count($str2)) return $D; } } return -1; } $a = "test"; $b = "test2"; $edo = edit_distance_ond($a,$b); echo $edo; ?>
Output for 7.2.0
Warning: count(): Parameter must be an array or an object that implements Countable in /in/rvn6L on line 6 Warning: count(): Parameter must be an array or an object that implements Countable in /in/rvn6L on line 8 Warning: count(): Parameter must be an array or an object that implements Countable in /in/rvn6L on line 8 Warning: count(): Parameter must be an array or an object that implements Countable in /in/rvn6L on line 15 Warning: count(): Parameter must be an array or an object that implements Countable in /in/rvn6L on line 15 Warning: count(): Parameter must be an array or an object that implements Countable in /in/rvn6L on line 15 Warning: count(): Parameter must be an array or an object that implements Countable in /in/rvn6L on line 20 Warning: count(): Parameter must be an array or an object that implements Countable in /in/rvn6L on line 20 0
Output for 4.3.0 - 7.1.10
0