Created
October 31, 2016 15:48
-
-
Save theredstapler/0b60e51be5dc66a63652cb73ddc70480 to your computer and use it in GitHub Desktop.
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 | |
$index = $_GET['data']; | |
//accessing database | |
$database = Array ( | |
"SP500"=>2128.19, | |
"DOW"=>18150.44, | |
"NASDAQ"=>5194.41 | |
); | |
if(isset($database[$index])) | |
responseJSON(200,"Success",$index,$database[$index]); | |
else | |
responseJSON(200,"Not Found",$index,""); | |
function responseJSON($status, $msg, $index, $value){ | |
header("Content-type:application/json"); | |
header("HTTP/1.1 $status $msg"); | |
$resp['index'] = $index; | |
$resp['value'] = $value; | |
echo json_encode($resp); | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment