3v4l.org

run code in 300+ PHP versions simultaneously
<?php function getNgrams($match, $n = 2) { $nGrams = []; for ($pos = strlen($match) - $n; $pos >= 0; --$pos) { $nGrams[] = substr($match, $pos, $n); } return $nGrams; } $question = 'happy birthday'; $questionNGrams = array_map("getNgrams", explode(' ', $question)); $rta = ['today', 'happy', ' tomorrow ', 'monday', 'birthda']; foreach ($rta as $value) { $rtaNGram = getNgrams($value); $rtaNGramCount = count($rtaNGram); foreach ($questionNGrams as $questionNGram) { if (count(array_intersect($rtaNGram, $questionNGram)) / $rtaNGramCount >= 0.8) { echo "{$value}<br>"; break; } } }
Output for git.master, git.master_jit, rfc.property-hooks
happy<br>birthda<br>

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