3v4l.org

run code in 300+ PHP versions simultaneously
<?php function levenshteinDistance($a, $b) { echo("a = ".$a.",b = ".$b); $matrix = array(count($a) + 1); echo("matrix=".$matrix); for ($i=0; $i<count($a)+1; $i++) { $matrix[$i] = array(count($b) + 1); echo("matrix[".$i."]=".$matrix[$i]); } for ($i=0; $i<count($a)+1; $i++) { $matrix[$i][0] = $i; } for ($j=0; $j<count($b)+1; $j++) { $matrix[0][$j] = $j; } for ($i=1; $i<count($a)+1; $i++) { for ($j=1; $j<count($b)+1; $j++) { //$x = $a[$i - 1] == $b[$j -1] ? 0 : 1; if($a[$i-1] == $b[$j-1]){ $x = 0; } else{ $x = 1; } $matrix[$i][$j] = min( $matrix[$i - 1][$j] + 1, $matrix[$i][$j - 1] + 1, $matrix[$i - 1][$j- 1] + $x ); } } return $matrix[count($a)][count($b)]; } echo levenshteinDistance("aaa","bbb"); ?>
Output for git.master, git.master_jit, rfc.property-hooks
a = aaa,b = bbb Fatal error: Uncaught TypeError: count(): Argument #1 ($value) must be of type Countable|array, string given in /in/EIWv2:4 Stack trace: #0 /in/EIWv2(34): levenshteinDistance('aaa', 'bbb') #1 {main} thrown in /in/EIWv2 on line 4
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:
35.92 ms | 401 KiB | 8 Q