阅读背景:

php 转json数据

来源:互联网 
<?php
/**
 * Created by PhpStorm.
 * User: Simtao
 * Date: 2018/5/3
 * Time: 23:19
 */
$data = array();
$data['time']=time();
$data['a'] = 'test';
$data['b'] = 'ccc';

if(file_exists('./test.json')){
    $toutiao = json_decode(file_get_contents('./test.json'),true);
    //if($toutiao['time']>@strtotime(date("Y-m-d"))){
    if(time()<=$toutiao['time']+60){
        foreach($data as $key=>$val){
                $toutiao = $val;
        }
        $data = $toutiao;
    }
}
// 写入文件
file_put_contents('./test.json', json_encode($data));<?php
/**
 * Created by PhpStorm.
 * User



你的当前访问异常,请进行认证后继续阅读剩余内容。

分享到: