3v4l.org

run code in 300+ PHP versions simultaneously
<?php $strings[] = 'seventy five yards out'; $strings[] = 'sixty yards out'; $strings[] = 'one hundred fifty yards out'; $inputString = 'seventy two yards out'; $inputWords = str_word_count($inputString, 1); $probabilities = []; foreach ($strings as $key => $string) { $stringWords = str_word_count($string, 1); $wordsCount = array_count_values($stringWords); $commonWords = array_intersect($inputWords, array_keys($wordsCount)); if (count($commonWords) > 0) { foreach ($commonWords as $commonWord) { if (!isset($probabilities[$key])) $probabilities[$key] = 0; $probabilities[$key] += $wordsCount[$commonWord]; } $probabilities[$key] /= count($stringWords); } } arsort($probabilities); print_r($probabilities); echo $strings[key($probabilities)];
Output for git.master, git.master_jit, rfc.property-hooks
Array ( [0] => 0.75 [1] => 0.66666666666667 [2] => 0.4 ) seventy five yards out

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:
80.31 ms | 405 KiB | 5 Q