order.php
785 Bytes
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
<?php
$orders = array(array(
'id'=>1,
'date'=>'2010-08-13',
'customer_id'=>1
), array(
'id'=>2,
'date'=>'2010-07-14',
'customer_id'=>1
), array(
'id'=>3,
'date'=>'2010-01-22',
'customer_id'=>2
), array(
'id'=>4,
'date'=>'2010-11-06',
'customer_id'=>2
), array(
'id'=>5,
'date'=>'2010-12-29',
'customer_id'=>3
), array(
'id'=>6,
'date'=>'2010-03-03',
'customer_id'=>3
)
);
if (isset($_REQUEST['id'])) {
$id = $_REQUEST['id'];
foreach ($orders as &$order) {
if ($order['id'] == $id) {
echo json_encode($order);
break;
}
}
} else {
echo json_encode($orders);
}
?>