what I'm trying to do is display some values I get into an array, here is how my array comes:
{"latitude":53.4749648,"longitude":-2.2083765,"addresses":["219 Ashton Old Road, , , , , Manchester, Greater Manchester","221 Ashton Old Road, , , , , Manchester, Greater Manchester","Beswick Convenience Store, 217 Ashton Old Road, , , , Manchester, Greater Manchester","Treads, 223 Ashton Old Road, , , , Manchester, Greater Manchester","Wong Wong Bakery, 163 Ashton Old Road, , , , Manchester, Greater Manchester"]}
now what I'm trying to display are the values from the "addresses", I'm trying to do a "while", for all the values, and print each of them, each address basicaly, hope I've explained myself well.
Are you looking like this?
$json = '{"latitude":53.4749648,"longitude":-2.2083765,"addresses":["219 Ashton Old Road, , , , , Manchester, Greater Manchester","221 Ashton Old Road, , , , , Manchester, Greater Manchester","Beswick Convenience Store, 217 Ashton Old Road, , , , Manchester, Greater Manchester","Treads, 223 Ashton Old Road, , , , Manchester, Greater Manchester","Wong Wong Bakery, 163 Ashton Old Road, , , , Manchester, Greater Manchester"]}';
$arr = json_decode ($json, true);
echo "<pre>";print_r($arr); echo "</pre>";
foreach ($arr['addresses'] as $key=>$val) {
echo "<br />".$key. ' => '.$val;
}
Assume your variable data contains all the json, can't you just write like
foreach($data as $val){
echo $val["address"];
}