mardi 3 mars 2015

foreach inside static array


How can I replace the locations here with a foreach loop?


This is my array



$data = array(
'name' => Locations,
'data' => '{
"title":"USA",
"location":"World",
"levels":[
{
"id":"states",
"title":"States",
"locations":[
{
"id":"ca",
"title":"California",
"pin":"hidden",
"x":"0.0718",
"y":"0.4546",
},
{
"id":"wa",
"title":"Washington",
"pin":"hidden",
"x":"0.1331",
"y":"0.0971"
}
]
}
]
}'


Here is my current foreach



foreach ($response->records as $record) {
$id = $record->Id;
$title = $record->Title;
$pin = $record->Pin;
$x = $record->X;
$y = $record->Y;

echo {
"id": $id,
"title": $title,
"pin": $pin,
"x": $x,
"y": $y
}
}


Any help would be appreciated.





Aucun commentaire:

Enregistrer un commentaire