$query = 't';
$words = [
'habr',
'test',
];
usort($words, function ($first, $second) use ($query) {
similar_text($query, $first, $firstPercent);
similar_text($query, $second, $secondPercent);
return $firstPercent < $secondPercent;
});
echo "Запрос: $query", PHP_EOL;
echo 'Искомое слово: ', $words[0], PHP_EOL;