使用php循环json数组


Loop through json array with php

我不知道如何执行以下操作:我以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'];
 }