<?php
$testStrings = [
"H3||0",
"Hallo",
"aloha",
"h",
"hallo",
"hallå",
"hel",
"helicopter",
"hellacious",
"hello",
"hello y'all",
"hello yall",
"helów",
"hey hello",
"hola",
"hêllo",
"mellow yellow",
"try",
];
$needle = 'hello';
usort($testStrings, function($a, $b) use ($needle) {
similar_text($needle, $a, $percentA);
similar_text($needle, $b, $percentB);
return $percentB <=> $percentA;
});
var_export($testStrings);
preferences:
58.69 ms | 402 KiB | 5 Q