PHP转换成JSON数组,及PHP解析JSON数组。
json
适用于现代 C++ 的 JSON。
项目地址:https://gitcode.com/gh_mirrors/js/json
免费下载资源
·
PHP转换成JSON数组
PHP解析JSON数组
<?php
class Emp {
public $name = "";
public $hobbies = "";
public $birthdate = "";
}
$e = new Emp();
$e->name = "sachin";
$e->hobbies = "sports";
$e->birthdate = date('m/d/Y h:i:s a', "8/5/1974 12:20:03 p");
$e->birthdate = date('m/d/Y h:i:s a', strtotime("8/5/1974 12:20:03"));
echo json_encode($e);
?>
执行结果
{"name":"sachin","hobbies":"sports","birthdate":"08/05/1974 12:20:03 pm"}
PHP解析JSON数组
<?php
$postArray ='[{"data":{"hello":"world"},"type":"1234","date":"2012-10-30 17:6:9","user":"000000000000000","time_stamp":1351587969902}, {"data":{"hello":"world"},"type":"1234","date":"2012-10-30 17:12:53","user":"000000000000000","time_stamp":1351588373519}]';
$de_json = json_decode($postArray,TRUE);
$count_json = count($de_json);
for ($i = 0; $i < $count_json; $i++)
{
//echo var_dump($de_json);
$dt_record = $de_json[$i]['date'];
$data_type = $de_json[$i]['type'];
$imei = $de_json[$i]['user'];
$message = json_encode($de_json[$i]['data']);
}
?>
GitHub 加速计划 / js / json
41.72 K
6.61 K
下载
适用于现代 C++ 的 JSON。
最近提交(Master分支:1 个月前 )
960b763e
4 个月前
8c391e04
7 个月前
更多推荐
已为社区贡献8条内容
所有评论(0)