1.将jsonp数据转json格式
2.json检查数据的编码格式是否跟php一样,否则json_decode会失败
public function jsonp_decode($jsonp, $assoc = false) { $jsonp = trim($jsonp); if(isset($jsonp[0]) && $jsonp[0] !== '[' && $jsonp[0] !== '{') { $begin = strpos($jsonp, '('); if($begin) { $end = strrpos($jsonp, ')'); if($end) { $jsonp = substr($jsonp, $begin + 1, $end - $begin - 1); } } } $encode = mb_detect_encoding($jsonp, array("ASCII",'UTF-8',"GB2312","GBK",'BIG5')); if ($encode !== "UTF-8"){ $jsonp = iconv($encode,"UTF-8",$jsonp); } return json_decode($jsonp,$assoc); }