比如 $str = {"weatherinfo":{"city":"北京"}} ;
$arr = json_decode($str,true); //后面加true转换为数组
echo $arr['weaterinfo']['city'] 就会输出 北京
前提是:你的源码保存文件必需是UTF-8格式,输出也要使用UTF-8输出。
header("Content-type:text/html;charset=utf-8");
我想知道php怎么获取拼接链接的json,就是在文本中输入一个值,按这个值去获取json