3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $suggestedMunicipalities = [ 'Bělá nad Radbuzou', 'Bělá nad Svitavou', ]; $query = 'Bělá nad'; usort($suggestedMunicipalities, function ($a, $b) use ($query) { $aDistance = levenshtein($query, $a, 1, 1000, 1000); $bDistance = levenshtein($query, $b, 1, 1000, 1000); return $aDistance - $bDistance; }); var_dump($suggestedMunicipalities);
based on Hv6uR
Output for 7.0.0 - 7.2.0
array(2) { [0]=> string(19) "Bělá nad Radbuzou" [1]=> string(19) "Bělá nad Svitavou" }
Output for 5.4.10 - 5.6.28
array(2) { [0]=> string(19) "Bělá nad Svitavou" [1]=> string(19) "Bělá nad Radbuzou" }
Output for 5.3.20 - 5.3.29
Parse error: syntax error, unexpected '[' in /in/5VSCS on line 3
Process exited with code 255.