Created
March 21, 2021 15:00
-
-
Save dreambo4/964bb49711a6f2f595c845e6eb91fd72 to your computer and use it in GitHub Desktop.
給 APP 練習用 - GET
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
header('Content-Type: application/json; charset=utf-8'); | |
$id = $_GET['id']; | |
$data = array( | |
"0" => array( | |
"name" => "八方雲集", | |
"address" => "台中市沙鹿區英才路17號" | |
), | |
"1" => array( | |
"name" => "微豆豆花", | |
"address" => "台中市沙鹿區英才路10號" | |
), | |
"2" => array( | |
"name" => "NU PASTA", | |
"address" => "台中市沙鹿區北勢東路583號1樓" | |
) | |
); | |
if (isset($id) || !empty($id)) { | |
if (!empty($data[$id])) { | |
$json = array( | |
"data" => array($data[$id]), | |
"success" => 1, | |
"message" => "get no. $id" | |
); | |
} else { | |
$json = array( | |
"data" => array(), | |
"message" => "wrong key!", | |
"success" => -1 | |
); | |
} | |
} else { | |
$json = array( | |
"data" => $data, | |
"success" => 2, | |
"message" => "get all" | |
); | |
} | |
print(json_encode($json)); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment