很难解释,但我需要一些帮助。所以我有 4 个字符串
$query = 'google awesome';
,
$result1 = 'google is cool';
,
$result1 = 'google is awesome';
和
$result3 = 'other page';
.
假设我使用了 PHP similar_text();
,并且$result1
60% 相似,$result2
70% 相似,$result3
5% 相似。
我如何按照从高到低的顺序呼应它们。请注意,我使用了 3 个以上的字符串,我只是使用foreach();
.
编辑:这是我的一段代码。
if(isset($_GET['q'])) {
$results = file(__DIR__ . '/data/urls.txt');
$query = $_GET['q'];
foreach($results as $result) {
$explode = explode('::', $result);
$site = $explode[0];
$title = $explode[1];
/* if $query = similar to $title, echo ordered by similarity. */
}
}