Loop over Array and get the distinct ids

Question

I’ve made a loop that goes over all the gigs I’ve attended, some gigs have the same songs.

Here is the result of that array:
http://snippi.com/s/k80v7pe

Now I want to have an array of all the distinct song id’s. So want to see all the songs that I’ve ever heard:

//get the songs field get_field('songs')
foreach ($postIds as $postId){ 
    array_push($songIds, get_field('songs', $postId));  
} 

//Over here I'm trying to print all the ID's of the song
foreach ($songIds as $songId) {
    echo $songId->ID;
}

But I’m getting the following error:
Notice: Trying to get property ‘ID’ of non-object in

Is that because of that the array $songIds has an array in an array?

Thanks

0
, , Dennis 2 years 2019-11-24T06:32:39-05:00 0 Answers 96 views 0

Leave an answer

Browse
Browse