From 59549b6b06687c2f5f07fefc03d115e8de906c85 Mon Sep 17 00:00:00 2001 From: Jacek Kowalski <Jacek@jacekk.info> Date: Fri, 17 Mar 2017 18:35:51 +0000 Subject: [PATCH] Add installation documentation --- stops.php | 10 ++++++++-- 1 files changed, 8 insertions(+), 2 deletions(-) diff --git a/stops.php b/stops.php index b9b0132..86abb6b 100644 --- a/stops.php +++ b/stops.php @@ -46,18 +46,24 @@ // Build structure for UI $stop_list = []; + $query_lower = mb_strtolower($_GET['query'], 'UTF-8'); foreach($ids as $id) { $stop_list[] = [ 'id' => $id, 'name' => $stops[$id], 'type' => 'stop', - 'relevance' => similar_text($_GET['query'], $stops[$id]) + 'relevance' => similar_text( + $query_lower, + mb_strtolower($stops[$id], 'UTF-8') + ) ]; } // Sort stops by relevence usort($stop_list, function($a, $b) { - return $b['relevance'] - $a['relevance']; + $rel = $b['relevance'] - $a['relevance']; + if($rel == 0) return strcasecmp($a['name'], $b['name']); + return $rel; }); // Return JSON -- Gitblit v1.9.1