I apologize for the title beforehand, but wasn't even sure how to ask the question.
I am working with a json array from a youtube feed. The feed for a playlist and a user upload are formatted a little differently. In order to reduce the amount of code I want to define the elements based on the type of feed (playlist/user upload) and insert that into my foreach statement.
The foreach statement for user uploads looks like this:
foreach ($json_output->data->items as $data) {}
and for the playlist it needs to look like this:
foreach ($json_output->data->items->video as $data) {}
I have tried defining the statement in a variable beforehand and doing something as follows with no luck:
foreach ($json_output.$feedtype as $data) {}
or
foreach ($json_output + $feedtype as $data) {}