jej07
asked on
combine and return contents of multiple cached files
Currently I have separate cached files for each of our YouTube playlists. The videos from each playlist is retrieved as needed by sending the playlist title to the Video function below.
Now, rather than just retrieving videos from one playlist, I would like to return all videos from specific playlists. I thought this could be done by looping through an array of playlists I was interested in, but it's breaking the page and giving me an array error "Fatal error: Cannot use object of type stdClass as array" (See function Videos_test). Any help you could provide would be greatly appreciated.
Now, rather than just retrieving videos from one playlist, I would like to return all videos from specific playlists. I thought this could be done by looping through an array of playlists I was interested in, but it's breaking the page and giving me an array error "Fatal error: Cannot use object of type stdClass as array" (See function Videos_test). Any help you could provide would be greatly appreciated.
function Videos($tag)
{
$cachefile = $tag;
$videos = array();
//Check the cache file
if(file_exists($this->cachefile_directory . $cachefile)){
$data = @file_get_contents($this->cachefile_directory . $cachefile);
$data = json_decode($data);
return $data->{"videos"};
} else {
return false;
}
}
function Videos_test($tag)
{
$cachefileArr = array('List 1', 'List 3', 'List 5');
$videos = array();
foreach($cachefileArr as $cachefile)
{
//Check the cache file
if(file_exists($this->cachefile_directory . $cachefile)){
$data = @file_get_contents($this->cachefile_directory . $cachefile);
$data = json_decode($data);
$list = $data['videos'];
$videoData .= $list;
}
}
return $videoData;
}
Is there more to this? Maybe if we have a complete PHP script and the line number we can go after the problem with some test cases.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Went a different route.