order.php 785 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. <?php
  2. $orders = array(array(
  3. 'id'=>1,
  4. 'date'=>'2010-08-13',
  5. 'customer_id'=>1
  6. ), array(
  7. 'id'=>2,
  8. 'date'=>'2010-07-14',
  9. 'customer_id'=>1
  10. ), array(
  11. 'id'=>3,
  12. 'date'=>'2010-01-22',
  13. 'customer_id'=>2
  14. ), array(
  15. 'id'=>4,
  16. 'date'=>'2010-11-06',
  17. 'customer_id'=>2
  18. ), array(
  19. 'id'=>5,
  20. 'date'=>'2010-12-29',
  21. 'customer_id'=>3
  22. ), array(
  23. 'id'=>6,
  24. 'date'=>'2010-03-03',
  25. 'customer_id'=>3
  26. )
  27. );
  28. if (isset($_REQUEST['id'])) {
  29. $id = $_REQUEST['id'];
  30. foreach ($orders as &$order) {
  31. if ($order['id'] == $id) {
  32. echo json_encode($order);
  33. break;
  34. }
  35. }
  36. } else {
  37. echo json_encode($orders);
  38. }
  39. ?>