【发布时间】:2017-06-30 13:36:47
【问题描述】:
这是我的代码,我正在尝试遍历这个 json,所以我想要做的是当 isset($_GET['latest=1'])) 它应该显示上面 json 中的一个对象,如果 latest=15 它应该显示 15 个对象,怎么能我这样做
<?php
header('Content-Type: application/json');
if(isset($_GET['latest']))
echo
'
{
"contacts": [
{
"id": "c200",
"name": "Ravi Tamada",
"email": "ravi@gmail.com",
"address": "xx-xx-xxxx,x - street, x - country",
"gender" : "male",
"url": "http://149.202.196.143:8000/live/djemal/djemal/592.ts"
},
{
"id": "c201",
"name": "Johnny Depp",
"email": "johnny_depp@gmail.com",
"address": "xx-xx-xxxx,x - street, x - country",
"gender" : "male",
"url":"http://149.202.196.143:8000/live/djemal/djemal/592.ts"
},
{
"id": "c202",
"name": "Leonardo Dicaprio",
"email": "leonardo_dicaprio@gmail.com",
"address": "xx-xx-xxxx,x - street, x - country",
"gender" : "male",
"url":"http://149.202.196.143:8000/live/djemal/djemal/592.ts"
}
]
}
';
【问题讨论】:
-
你从哪里获取数据 - 从数据库?