commit | author | age
|
ced309
|
1 |
<?php |
JK |
2 |
if(php_sapi_name() !== 'cli') die(); |
|
3 |
|
|
4 |
$chars = 'aąbcćdeęfghijklłmnńoóprsśtuvwxyzżź0123456789'; |
|
5 |
$len = mb_strlen($chars); |
|
6 |
|
|
7 |
$replacements = [ |
|
8 |
'Ó' => 'Ó', |
|
9 |
'ó' => 'ó', |
|
10 |
'É' => 'É', |
|
11 |
'é' => 'é', |
|
12 |
]; |
|
13 |
|
|
14 |
$stops = []; |
|
15 |
for($i = 0; $i < $len; $i++) { |
|
16 |
for($j = 0; $j < $len; $j++) { |
|
17 |
$char = mb_substr($chars, $i, 1).mb_substr($chars, $j, 1); |
|
18 |
$json = file_get_contents('http://www.ttss.krakow.pl/internetservice/services/lookup/autocomplete/json?query='.urlencode($char)); |
|
19 |
$elements = json_decode($json, 1); |
|
20 |
foreach($elements as $element) { |
|
21 |
if($element['type'] == 'divider') continue; |
|
22 |
if($element['type'] == 'route') continue; |
|
23 |
if($element['type'] != 'stop') { |
|
24 |
throw new Exception('Unknown element: '.var_export($element, 1)); |
|
25 |
} |
|
26 |
|
|
27 |
$stops[$element['id']] = strtr($element['name'], $replacements); |
|
28 |
} |
|
29 |
} |
|
30 |
} |
|
31 |
|
|
32 |
asort($stops); |
|
33 |
var_export($stops); |