请用json_decode解析成数组
jsonp107({"SM_368_dsr-1097280647":{v:0,nv:100,m_UFB:0,m:4.89661,m_g:20.15,s_UFB:0,s:4.8744,s_g:31.49,c_UFB:0,c:4.87867,c_g:39.55,gp:100.00,ss:290167,hdr:true},"ICCP_1_522177046867":4915});
我要取4915这个值,请用json_decode解析成数组来取值。
求这几行代码
------解决思路----------------------
$s =<<< TXT<br />jsonp107({"SM_368_dsr-1097280647":{v:0,nv:100,m_UFB:0,m:4.89661,m_g:20.15,s_UFB:0,s:4.8744,s_g:31.49,c_UFB:0,c:4.87867,c_g:39.55,gp:100.00,ss:290167,hdr:true},"ICCP_1_522177046867":4915});<br />TXT;<br />$s = preg_replace_callback('/[-".\w]+/',<br /> function($m) { return '"' . trim($m[0],'"') . '"'; },<br /> preg_replace('/^.+\((.+)\).+$/', '$1', $s));<br />print_r(json_decode($s, 1));<br />
Array<br />(<br /> [SM_368_dsr-1097280647] => Array<br /> (<br /> [v] => 0<br /> [nv] => 100<br /> [m_UFB] => 0<br /> [m] => 4.89661<br /> [m_g] => 20.15<br /> [s_UFB] => 0<br /> [s] => 4.8744<br /> [s_g] => 31.49<br /> [c_UFB] => 0<br /> [c] => 4.87867<br /> [c_g] => 39.55<br /> [gp] => 100.00<br /> [ss] => 290167<br /> [hdr] => true<br /> )<br /><br /> [ICCP_1_522177046867] => 4915<br />)<br /><br />