Home  >  Article  >  Backend Development  >  为何这一个js数据不能 json_decode

为何这一个js数据不能 json_decode

WBOY
WBOYOriginal
2016-06-13 11:15:571171browse

为什么这一个js数据不能 json_decode 啊

本帖最后由 xiachao2008 于 2013-02-27 10:07:08 编辑
        $url = "http://info.live8bo1.com:90/rjs/2012/0513_score.js?r=0.4787992987028289";<br />        echo $html = file_get_contents($url);<br />        $data_a = json_decode($html);<br />        echo "<pre class="brush:php;toolbar:false">";print_r($data_a);


------解决方案--------------------
<br />		header("content-type:text/html;charset=utf-8");<br />	    $url = "http://info.live8bo1.com:90/rjs/2012/0513_score.js?r=0.4787992987028289";<br />        $html = trim(file_get_contents($url));<br />		if(ord($html[0])== 239 && ord($html[1])== 187 && ord($html[2]) == 191){<br />			$html = substr($html,3);<br />		}<br />		eval("\$data='$html';");<br />		echo "<pre class="brush:php;toolbar:false">";<br />        print_r(json_decode($data,true));<br />
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn