我不知道如何执行以下操作:我以 json 形式检索 mysql 请求,并得到以下结果:
[
{"pid":"1","comment":"La premiere consultation est toujours bizarre..."},
{"pid":"1","comment":"La seconde... c'est jamais mieux !"}
]
现在我正在尝试循环它来生成我的 html 模板。我绝对不是 php 专家,但正在学习:)
感谢您的帮助!
最佳答案
Thank you Mark, this worked out fine !
$arr = json_decode($json, true);
foreach($arr as $item) { //foreach element in $arr
echo 'Comment: ' . $item['comment'];
}
关于php - 使用 php 循环 json 数组,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34257396/