The json return value includes the function name. how does one perform callback in PHP? This post was finally crawled by zlbpolly at 2014-08-2621: 22: 37. now I can only cut the string and filter out the function name, then the value is in json format. Is there a way to directly call back the function? Jsonp3 ({& nbsp; status: & nbsp; 200, & nbsp json return value with function name, how to call back in PHP?
This post was last edited by zlbpolly at 21:22:37
The following content is captured. now I can only take a string, filter out the function name, and then take the value in json format.
Is there a way to directly call back the function?
Jsonp3 ({"status": 200, "ercode": 0 });
------ Solution --------------------
No good way, because php does not support writing objects {}
I don't know how you filtered out the function name.
Php5.4 and below can be written
$ S = 'jsonp3 ({"status": 200, "ercode": 0 })';
Preg_replace ('/^ \ w +? \ (. +) \) $/Ise ', 'Count ($ r = json_decode ("$1")', $ s );
Print_r ($ r );
Php5.3 and above can be written
$ S = 'jsonp3 ({"status": 200, "ercode": 0 })';
Preg_replace_callback ('/^ \ w +? \((. +) \) $/Is ', function ($ m) use (& $ r) {$ r = json_decode ($ m [1]) ;}, $ s );
Print_r ($ r );