0

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.

Priya Rajaram
  • 340
  • 2
  • 14

3 Answers3

1

Cast to an array

$array = (array) $object;

Or, use get_object_vars

$array = get_object_vars($object);
cnjap
  • 380
  • 3
  • 6
  • 24
0

You can just typecast it:

$array =  (array) $yourObject;

This will create an associative array from your object.

BlackHatSamurai
  • 23,275
  • 22
  • 95
  • 156
0

Aws\Result has a method toArray()

Source

Matheus Maximo
  • 149
  • 1
  • 8