Home  >  Article  >  Backend Development  >  请用json_decode解析成数组

请用json_decode解析成数组

WBOY
WBOYOriginal
2016-06-20 12:45:061095browse

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解析成数组来取值。

求这几行代码


回复讨论(解决方案)

http://bbs.csdn.net/topics/391853070?page=1#post-400534281
我给你答了 虽然有点蠢 但是勉强算是你要的效果吧。

或者等待大神给你来答

$s =<<< TXTjsonp107({"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});TXT;$s = preg_replace_callback('/[-".\w]+/',   function($m) { return '"' . trim($m[0],'"') . '"'; },   preg_replace('/^.+\((.+)\).+$/', '$1', $s));print_r(json_decode($s, 1));
Array(    [SM_368_dsr-1097280647] => Array        (            [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)

楼主SB.不要说是学PHP的。真他妈丢人

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