3v4l.org

run code in 300+ PHP versions simultaneously
<?php function similarity($str1, $str2) { $len1 = strlen($str1); $len2 = strlen($str2); $max = max($len1, $len2); $similarity = $i = $j = 0; while (($i < $len1) && isset($str2[$j])) { if ($str1[$i] == $str2[$j]) { $similarity++; $i++; $j++; } elseif ($len1 < $len2) { $len1++; $j++; } elseif ($len1 > $len2) { $i++; $len1--; } else { $i++; $j++; } } return round($similarity / $max, 2); } $str1 = '12345678901234567890'; $str2 = '12345678991234567890'; echo 'Similarity: ' . (similarity($str1, $str2) * 100) . '%'; ?>
Output for git.master, git.master_jit, rfc.property-hooks
Similarity: 95%

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:
57.26 ms | 401 KiB | 8 Q