ph解码jsonp数据

//jsonp解码  第二个参数传入true则解码为php数组
function jsonp_decode($jsonp, $assoc = false) {
  if($jsonp[0] !== '[' && $jsonp[0] !== '{') {
    $jsonp = substr($jsonp, strpos($jsonp, '('));
  }
  return json_decode(trim($jsonp,'();'), $assoc);
}

  

posted @ 2017-12-11 20:38  全帅  阅读(232)  评论(0编辑  收藏  举报