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.

    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;
    }

Open in new window

LVL 1
jej07Asked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Ray PaseurCommented:
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.
0
jej07Author Commented:
Thank you for your response. I approached this from a different angle and no longer need to combine the playlists.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
jej07Author Commented:
Went a different route.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
PHP

From novice to tech pro — start learning today.