-
Notifications
You must be signed in to change notification settings - Fork 0
/
stogdata.php
42 lines (31 loc) · 926 Bytes
/
stogdata.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
<?php
$uic = $_POST['uic'];
$url = 'http://wap.dsb.dk/servlet/WapServlet?stationsid='.$uic;
$file = file_get_contents($url);
$seperated = str_replace('<br/>', ';', $file);
$stripped = strip_tags($seperated);
$list = array_filter(explode(';', $stripped));
$output = array();
$count = 0;
foreach ($list as $entry){
$count++;
if($count != count($list)){
if (!preg_match('/[\d\x{00BD}]+/', $entry)){
if(strpos($entry, 'Tilbage') === FALSE) {
$output[] = array('head' => utf8_encode($entry));
}
}
else {
if (preg_match('/^([\w]+) (.*) ([\d\x{00BD}]+)$/', $entry, $matches)) {
$station_info = array_splice($matches, 1);
$output[] = array(
'line' => ucfirst(strtolower($station_info[0])),
'destination' => utf8_encode($station_info[1]),
'departure' => utf8_encode($station_info[2]),
);
}
}
}
}
print json_encode($output);
?>