1.
Return is this format, PHP json_decode (), not directly parse, should be a variety of cutting string into JSON format, in the use of Json_decode ();
This is the standard JSON format.
2.
This is particularly close to the JSON format, but it is still unresolved.
You have a good way.
Reply content:
1.
Return is this format, PHP json_decode (), not directly parse, should be a variety of cutting string into JSON format, in the use of Json_decode ();
This is the standard JSON format.
2.
This is particularly close to the JSON format, but it is still unresolved.
You have a good way.
This is not the problem
Not like a problem.
Get it out honestly.
$res = file_get_contents('https://tcc.taobao.com/cc/json/mobile_tel_segment.htm?tel=15011923452'); /*"__GetZoneResult_ = { mts:'1501192', province:'广东', catName:'中国移动', telString:'15011923452', areaVid:'30517', ispVid:'3236139', carrier:'广东移动'}"*/ $res = trim(explode('=',$res)[1]); $res = iconv('gbk','utf-8', $res); $res = str_replace("'",'"', $res); $res = preg_replace('/(\w+):/is', '"$1":', $res); print_r(json_decode($res,1)); /*Array( [mts] => 1501192 [province] => 广东 [catName] => 中国移动 [telString] => 15011923452 [areaVid] => 30517 [ispVid] => 3236139 [carrier] => 广东移动)*/
PHP words must be extracted into a JSON string before the line.
This is a JS Property object ...
If you are not afraid of the risk of XSS injection, you can throw it directly into JS.
Take it all out, and remove the first {before you use a regular =>json.parse