customer.php 573 B

12345678910111213141516171819202122232425262728
  1. <?php
  2. $customers = array(array(
  3. 'id'=>1,
  4. 'name'=>'Bread Barn',
  5. 'phone'=>'8436-365-256'
  6. ), array(
  7. 'id'=>2,
  8. 'name'=>'Icecream Island',
  9. 'phone'=>'8452-389-719'
  10. ), array(
  11. 'id'=>3,
  12. 'name'=>'Pizza Palace',
  13. 'phone'=>'9378-255-743'
  14. )
  15. );
  16. if (isset($_REQUEST['id'])) {
  17. $id = $_REQUEST['id'];
  18. foreach ($customers as &$customer) {
  19. if ($customer['id'] == $id) {
  20. echo json_encode($customer);
  21. break;
  22. }
  23. }
  24. } else {
  25. echo json_encode($customers);
  26. }
  27. ?>