Trouble accessing an array

Posted 1 year ago by gregghoush

I am attempting to use Rob Brazier's Laravel-Piwik package to grab information from my Piwik install. I have this code to get visits to blog posts in the past week. It gives me an object, which contains an array, which is made up of objects.

        $visits = Piwik::getActions();
        $visits = $visits->getPageUrls(['period' => 'week', 'expanded' => '1', 'segment' => '']);
        //$visits = $visits->subtable[0];

This works, it gets me the object and the dd shows it to me.

Here is the object it gives me:

If I uncomment the commented out line there I get this error: Trying to get property "subtable" of non-object.

How do I access that array "subtable"? I would like to loop through it with a foreach.

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

Laracasts Mascot

Hi, Have We Met Yet?

Did you know that, in addition to the forum, Laracasts includes well over 1000 lessons on modern web development? All for the price of one lunch out per month.

Sign Me Up


Reply to

Use Markdown with GitHub-flavored code blocks.