php loop through json array code example
Example 1: php loop through json
$arr = json_decode('[{"var1":"9","var2":"16","var3":"16"},{"var1":"8","var2":"15","var3":"15"}]');
foreach($arr as $item) { //foreach element in $arr
$uses = $item['var1']; //etc
}
Example 2: php json key value loop
$json = '{"1":"a","2":"b","3":"c","4":"d","5":"e"}';
$obj = json_decode($json, TRUE);
foreach($obj as $key => $value)
{
echo 'Your key is: '.$key.' and the value of the key is:'.$value;
}