这是我的代码,我试图通过这个JSON循环,所以我想要做的是当isset($_GET['latest=1']))
它应该显示一个对象从JSON上面,如果最新= 15它应该显示15个对象,我该怎么做循环遍历JSON对象php
<?php
header('Content-Type: application/json');
if(isset($_GET['latest']))
echo
'
{
"contacts": [
{
"id": "c200",
"name": "Ravi Tamada",
"email": "[email protected]",
"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": "[email protected]",
"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": "[email protected]",
"address": "xx-xx-xxxx,x - street, x - country",
"gender" : "male",
"url":"http://149.202.196.143:8000/live/djemal/djemal/592.ts"
}
]
}
';
你从哪里取数据 - 从数据库? –