您好,我不知道如何遍历这个 json 编码数组并为每个对象获取其所有值。我需要每个值作为自己的变量。
echo json_encode($formulars);
这就是我回显时得到的
[{"project_name":"polle","type":"support","title":"vi","reason":"prover","solution":"igen","comments":"okay ","date_stamp":"2013-08-20 14:06:37","used_time":132},{"project_name":"dolla","type":"support","title":"lolol","reason":"skl","solution":"dskal","comments":"kflafda ","date_stamp":"2013-08-20 14:11:36","used_time":210},{"project_name":"polle","type":"fejl","title":"lol","reason":"aksdl","solution":"fdjks","comments":"djsks ","date_stamp":"2013-08-20 14:13:27","used_time":1230}]
我已经尝试了这段代码,并且设法从第一个对象中取出了 project_name,就是这样:
foreach ($formulars as $current => $project_name) {
$project_name['project_name'];
}
那么有什么方法可以获取数组中每个对象的所有变量,而不仅仅是 project_name?
像这样:
foreach ($formulars as $current){
$projectName = $current['project_name'];
$type = $current['type'];
$reason = $current['reason'];
}
提前致谢