我有JSON数组
[
{"id":"476","jobid":"324","remarks":"Job 500","status":"Open"},
{"id":"477","jobid":"324","remarks":"Job 501","status":"Closed"},
{"id":"481","jobid":"324","remarks":"Job 502","status":"Cancelled"}
]
如何使用PHP获得remarks
的状态Closed
?
可能的话最好不要循环
答案 0 :(得分:2)
没有循环,这取决于。
没有任何循环都是不可能的,但是循环可以在后台而不是在php中完成。
这将获取状态列,并过滤掉所有未关闭的内容。
然后设置“备注”的键。
var_dump(array_intersect(array_column($arr, 'status', 'remarks'), ["Closed"]));
输出:
array(1) {
["Job 501"]=>
string(6) "Closed"
}
答案 1 :(得分:1)
签出JQL:
$jql = new JQL('[
{"id":"476","jobid":"324","remarks":"Job 500","status":"Open"},
{"id":"477","jobid":"324","remarks":"Job 501","status":"Closed"},
{"id":"481","jobid":"324","remarks":"Job 502","status":"Cancelled"}
]');
$result = $jql->select('remarks')->where('status = Closed')->fetch();