Hard to explain, but I need some help.
So I have, say 4 strings
$query = 'google awesome';
,
$result1 = 'google is cool';
,
$result1 = 'google is awesome';
, and
$result3 = 'other page';
.
Lets say I used PHP's similar_text();
, and $result1
is 60% similar, $result2
is 70% similar and $result3
is 5% similar.
How do I echo them in order from highest to lowest. Note that I am using more that 3 strings, I just echo the results using foreach();
.
EDIT: HERE is my piece of code.
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. */
}
}