3v4l.org

run code in 300+ PHP versions simultaneously
<?php $matches = [ [ 'insult' => [ 'text' => 'You fight like a Dairy Farmer!', 'maxDistance' => 15, ], 'response' => [ 'text' => 'How appropriate! You fight like a cow!', 'maxDistance' => 20, ], ], [ 'insult' => [ 'text' => 'This is the END for you, you gutter crawling cur!', 'maxDistance' => 32, ], 'response' => [ 'text' => 'And I\'ve got a little TIP for you, get the POINT?', 'maxDistance' => 25, ], ], ]; $search = "This is the end for you, gutter-crawling cur!"; $closestSet = null; $closestScore = 0; foreach ($matches as $set) { $score = similar_text($search, $set['insult']['text']); var_dump($score); if ($score > $closestScore) { $closestScore = $score; $closestSet = $set; } } echo "---", PHP_EOL; var_dump($search, $closestScore, $closestSet);
Output for git.master, git.master_jit, rfc.property-hooks
int(10) int(41) --- string(45) "This is the end for you, gutter-crawling cur!" int(41) array(2) { ["insult"]=> array(2) { ["text"]=> string(49) "This is the END for you, you gutter crawling cur!" ["maxDistance"]=> int(32) } ["response"]=> array(2) { ["text"]=> string(49) "And I've got a little TIP for you, get the POINT?" ["maxDistance"]=> int(25) } }

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:
76.28 ms | 406 KiB | 5 Q