I have a for loop, it returns an id and the name of all the images a user has.
$from1 = 1;
$from2 = 10;
for ($i=$from1; $i < $from2; $i++) {
if (($i % 5) == 0)
$idTemp = $id1[$i];
echo $idTemp;
echo $name[$i];
}
Instead of echoing out the data, I wish to place it into a json response, like this:
"images":[
"1":{"id":"1234","name":"thisisaname"},
"2":{"id":"4332","name":"namename"}
]
But i can't seem to work out how to create json arrays inside a loop. Also how would i then loop through to decode the json?
Can anyone help? Cheers for any help in advance, Jamie