I am running into an issue trying to push an object into an Array in PHP. My Object looks like the below sample and has 2 empty array's. When i try to use the push_array function i get the error
PHP Fatal error: Uncaught Error: Cannot use object of type ResidentialListing as array in /var/www/html/PHRETS/retsphp.php:95
Not sure why as Changes is a Array.
Here is how i call it where $r is an Object but i get same error if i try to push string.
array_push($Listing['Changes'], $r);
Below is $Listing Object
object(ResidentialListing)#86 (5) {
["_id"]=>
string(36) "b77130b6-aea8-4325-9f04-fb77d2cc307f"
["_type"]=>
string(11) "Residential"
["Record"]=>
object(Residential_obj)#110 (18) {
["ListingId"]=>
string(9) "S09100062"
["ListingKeyNumeric"]=>
string(7) "4461874"
["StandardStatus"]=>
string(6) "Closed"
["PreviousStandardStatus"]=>
string(0) ""
["ParcelNumber"]=>
string(10) "6051018010"
["UniversalPropertyID"]=>
string(0) ""
["MLSAreaMajor"]=>
string(17) "699 - Not Defined"
["MajorChangeType"]=>
string(0) ""
}
["Images"]=>
array(0) {
}
["Changes"]=>
array(0) {
}
}
$Listingis an object use$Listing->Changes. And better, just do$Listing->Changes[] = $r;