Reputation: 964
I am using the BandsInTown API, and I'm trying to list all the event titles for a band. The code below works for the first title, but I need to look through all of them. I tried a foreach loop I found on here, but did have any luck. How do I show all the event titles for a particular band? I have been looking at previous questions like this one.
$json = file_get_contents("http://api.bandsintown.com/artists/Skrillex/events.json?api_version=2.0&app_id=MYID");
$data = json_decode($json);
echo $data[0]->title;
// I tried this, but it didn't work
foreach($data->title as $title){
echo $title;
}
Upvotes: 0
Views: 778
Reputation: 22711
Try this.,
foreach($data as $Events){
echo $Events->title."<br>";
}
Upvotes: 2
Reputation: 6319
I think you might be look for something like
foreach($data as $datum){
echo $datum->title;
}
Upvotes: 3