Reputation: 360
I have an object in php.
Object ( [data:Aws\Result:private] => Array ( [Reservations] => Array ( ) [@metadata] => Array ( [statusCode] => 200 [effectiveUri] => https://google.com [headers] => Array ( [content-type] => text/xml;charset=UTF-8 [transfer-encoding] => chunked [vary] => Accept-Encoding [date] => Fri, 27 Nov 2015 07:03:59 GMT [server] => AmazonEC2 ) ) ) )
I need to convert this object to array in php.
can i get any help please?
thanks.
Upvotes: 0
Views: 457
Reputation: 500
Cast to an array
$array = (array) $object;
Or, use get_object_vars
$array = get_object_vars($object);
Upvotes: 1
Reputation: 23483
You can just typecast it:
$array = (array) $yourObject;
This will create an associative array from your object.
Upvotes: 0