Can't turn an object into an array.

Posted 11 months ago by ChrisF79

Just starting to work on something and I have the following code:

class ProcessRetsListings
{

    public function __construct($results)
    {
        $this->results = $results;
    }

    public function process($results)
    {
        $results->toArray();
        foreach ($results as $result)
        {
            echo $result['StreetName'];
        }
    }
}

I ran a php gettype($results) and it is in fact an object. I try to turn it into an array and I get the error: Call to undefined method App\Models\RetsFeedApiResult::toArray()

I need it to be an array so I can work with it and ultimately save the entire result to the database.

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

Reply to

Use Markdown with GitHub-flavored code blocks.