/******************************************************************************
* PHP JSON文件解析并获取key、value,判断key是否存在
* 说明:
* 配置文件以JSON格式存放在文件中,key、value都是未知且要被处理的数据。
* 2017-3-14 深圳 南山平山村 曾剑锋
*****************************************************************************/
一、参考文档:
1. Getting JSON data with PHP
http://stackoverflow.com/questions/16578019/getting-json-data-with-php
2. how to know whether key exists in Json string [duplicate]
http://stackoverflow.com/questions/10176293/how-to-know-whether-key-exists-in-json-string
二、操作方法
1. 获取json的key、value:
$string = file_get_contents("jsonFile.json");
$json_array = json_decode($string,true);
foreach ($json_array as $key => $value){
$store = $key -> store;
$general_cat = $key -> general_cat;
$spec_cat = $key -> spec_cat;
if (!is_null($key -> mainImg_select)){
$cat = $key -> cat;
echo $headURL;
2. 判断key是存在的,并且非空:
1. 处理方法:
if( isset( $mydata['user_id'] ) ){
// do something
2. array_key_exists、isset这两个函数对值为空的返回值是不一样的。
2.shell命令概述 Shell作用:命令解释器 介于操作系统内核与用户之间,负责解释命令行 获得命令帮助 内部命令help 命令的“--help” 选项 使用man命令阅读手册页 命令行编辑的几个辅助
3.微信小程序 video 9:16播放视频动态显示:objectFit属性值 非全屏cover全屏fill
4.趣解设计模式之《小王看病记》
5.python代码的注释