ChrisF79
2 months ago

Cannot create a simple array

Posted 2 months ago by ChrisF79

I'm trying to create an array as I loop through some records of my database. The records are there but after the loop when I print_r the $sitemap, it is empty. It should have about 27k records in it.

Here is my code:

        Listing::where('Inactive', '=', 0)
            ->where('Status', '=', 'Active')
            ->chunk(200, function($listings) {
            foreach($listings as $listing) {
                $sitemap[] = array (
                    $cleanURL = "https://listingnaples.com/listing/" . $listing->MLSNumber . "/" . $listing->CleanAddressURL,
                    "loc" => $cleanURL,
                    "changefreq" => "daily",
                    "priority" => "0.90"
                );
            }
        });

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