-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgetstation.php
47 lines (44 loc) · 1.25 KB
/
getstation.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
43
44
45
46
47
<?php
include('weather.php');
header('Content-type: application/json');
if (array_key_exists('id', $_REQUEST)) {
$id = $_REQUEST['id'];
for ($i=0; $i<count($stations); ++$i) {
if ($stations[$i]['id'] == $id) {
print json_encode($stations[$i]);
break;
}
}
} else {
print json_encode($stations);
}
// print(
// '{' .
// ' "title": "A cool blog post",' .
// ' "clicks": 4000,' .
// ' "children": null,' .
// ' "published": true,' .
// ' "comments": [' .
// ' {' .
// ' "author": "Mister X",' .
// ' "message": "A really cool posting"' .
// ' },' .
// ' {' .
// ' "author": "Misrer Y",' .
// ' "message": "It is me again!"' .
// ' }' .
// ' ]' .
// '}'
// );
//
// // print("{'stations':[");
// // for ($i=0; $i<count($stations); ++$i) {
// printf("{'id':'%s','name':'%s','lat':%.4f,'lon':%.4f,'elev':%.2f,'state':'%s'},\n",
// $stations[$i]['id'],
// $stations[$i]['name'],
// $stations[$i]['lat'],
// $stations[$i]['lon'],
// $stations[$i]['elev'],
// $stations[$i]['state']);
// }
// print("]}\n");