I have a json string derived from MySQL query using GROUP_CONCAT
(which returns STRING).
Here's JSON string as field portfolios
:
[
{name:"Branch GBD_1.pdf", img_path:"1333752771.pdf"},
{name:"Doc.pdf", img_path:"2020107119.pdf"},
{name:"COK.pdf", img_path:"264860069.pdf"}
]
Now in php, I tried to decode the field and loop through it, but I am not being able to.
foreach($records as $r)
{
$varArray = json_decode($r['portfolios'], true);
foreach($varArray as $que)
{
echo $que['name'].' '.$que['img_path'];
echo '<br/>';
}
}
How do I break or convert the variable into loop-able object?