微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

php中输出json对象的值(实现方法)

实例如下所示:

rush:xhtml;"> PHP

$json = '{"report":{"date":"2012-04-10","content":"abcdefght"}}';
$arr = (array) json_decode($json,true);
echo '当前日期是:'. $arr['report']['date'];
echo "
";
echo '

';
print_r($arr);
echo '
';

foreach($arr as $arrvalue)
{
foreach($arrvalue as $key=>$value)
{
echo "[$key] = $value
";
}
}
echo "
";
?>

rush:xhtml;"> PHP $file_exists = file_exists("json.txt"); if( $file_exists ){ $myfile = fopen("json.txt","r") or die(""); $content = fread($myfile,filesize("json.txt")); fclose($myfile); echo $content; echo "
"; $arr=(array)json_decode($content,true); echo $arr['CSS']; echo "
"; echo $arr['AJAX']; } ?>

json.txt:

rush:xhtml;"> { "AJAX": "Asynchronous JavaScript and XML","CSS": "Cascading Style Sheets" }

以上这篇PHP输出json对象的值(实现方法)就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持编程之家。

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐