php curl获取到json对象并转成数组array的方法
例子:
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);
相关推荐
83911535 2020-11-13
曾是土木人 2020-10-31
yegen00 2020-10-21
soralaro 2020-10-11
katanaFlower 2020-09-18
wytzsjzly 2020-08-17
88407710 2020-08-17
ChinaJoeEE 2020-08-16
CyborgLin 2020-08-15
Blueberry 2020-08-15
PinkBean 2020-08-11
katanaFlower 2020-08-03
hunningtu 2020-07-30
阿债的方寸天地 2020-06-28
pingyan 2020-06-25
wytzsjzly 2020-06-25
阳光岛主 2020-06-25
阿债的方寸天地 2020-06-16