dmcglone27
2 months ago
540
10
General

displaying an array

Posted 2 months ago by dmcglone27

I am working with the youtube package from github and I am able to grab my videos from youtube and var_dump() displays them but when I use foreach in the controller I get:

Object of class stdClass could not be converted to string....

<--Controller-->

public function index()
    {
        $videoList = Youtube::listChannelVideos('UC7lpUYBACuDC6cPSMYRRMMQ', 5);
        
        foreach($videoList as $video) {
            echo $video;
            }

    }

And if I put the array in my blade like so:

<--controller-->

public function index()
    {
        $videoList = Youtube::listChannelVideos('UC7lpUYBACuDC6cPSMYRRMMQ', 5);

        return view('layouts.sectionLayout', compact('videoList'));

    }

<--View-->


@foreach($videoList as $video) {
                        {{ $video }}
                        @endforeach

I get the error htmlspecialchars() expects parameter 1 to be string, object given

What am I forgetting or missing or not understanding?

Please sign in or create an account to participate in this conversation.