php 如何将获取json中的参数的值
json格式{"code":200,"message":"解析成功。","source":"bilibili","sourceName":"哔哩哔哩","vid":"84...
json格式{"code":200,"message":"解析成功。","source":"bilibili","sourceName":"哔哩哔哩","vid":"8453162","info":{"title":"【7月】SHOW BY ROCK!! Short!! 01【独家正版】","duration":180,"image":"123456.jpg"},"result":{"duration":180.013,"files":[{"url":"123456.mp4","duration":180.013,"filesize":0,"filetype":"mp4"}],"h":2},"definition":"sd","definitionList":"sd|hd","cost":0.005}
我只想获取 url 里的 123456.mp4 以echo方式写出~ 求大神帮助 谢谢
这是一个URL里获取的json数据aa.php中,我是php小白 求大神给个例子~谢谢 展开
我只想获取 url 里的 123456.mp4 以echo方式写出~ 求大神帮助 谢谢
这是一个URL里获取的json数据aa.php中,我是php小白 求大神给个例子~谢谢 展开
3个回答
展开全部
首先 复制你的那条乱乱的json 然后打开
丢进去转换 然后替换下面的函数 即可
代码如下
$object = json_decode('
{
"code": 200,
"message": "解析成功。",
"source": "bilibili",
"sourceName": "哔哩哔哩",
"vid": "8453162",
"info": {
"title": "【7月】SHOW BY ROCK!! Short!! 01【独家正版】",
"duration": 180,
"image": "123456.jpg"
},
"result": {
"duration": 180.013,
"files": [
{
"url": "123456.mp4",
"duration": 180.013,
"filesize": 0,
"filetype": "mp4"
}
],
"h": 2
},
"definition": "sd",
"definitionList": "sd|hd",
"cost": 0.005
}
');
foreach($object as $key => $value){
if(is_object($value)){
foreach ($value as $k => $v){
echo $k . ' : ' . $v . '</br>';
}
}else{
echo $key . ' : ' . $value . '</br>';
}
}
望采纳~
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询