时间:2021-07-01 10:21:17 帮助过:14人阅读
例子:
function objtoarr($obj){ $ret = array(); foreach($obj as $key =>$value){ if(gettype($value) == 'array' || gettype($value) == 'object'){ $ret[$key] = objtoarr($value); }else{ $ret[$key] = $value; } } return $ret; } $ch = curl_init(); curl_setopt($ch, CURLOPT_URL,'http://www.tudou.com/albumcover/albumdata/getAlbumItems.html?acode=pEFBZGfERLo&charset=utf-8'); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_ENCODING, "gzip"); $output = curl_exec($ch); curl_close($ch); $content = json_decode($output); $content_arr = objtoarr($content); var_dump($content_arr);
以上就是本篇文章的全部内容了,感谢大家阅读。更多请关注PHP中文网!
相关推荐:
php curl 模拟登录并获取数据实例
php curl批处理实现可控并发异步操作案例详解
以上就是php curl获取到json对象并转成数组array的方法的详细内容,更多请关注Gxl网其它相关文章!