tags:

views:

88

answers:

2
<?php

   print_r($response->response->docs);

?>

display the following

Array ( [0] => Object ( [_fields:private] => Array ( [id]=>9093 [name]=>zahir) Object ( [_fields:private] => Array ( [id]=>9094 [name]=>hussain)..)

how to change the object to array...

i want the following

Array([0]=>([id]=>9093 [name]=>zahir) [1]=>([id]=>9094 [name]=>hussain)...)

can i do?

no one can answer....

+1  A: 

Have you tried casting the object to an array?

$array = (array) $object;

There's also a function available here or if you're using PHP >= 5.2 you could use the native JSON functions, decoding with true as the second param to force an associative array:

$json  = json_encode($object);
$array = json_decode($json, true);
Andy E
+1  A: 

You should look at get_object_vars , as your properties are declared private you should call this inside the class and return its results.

Be careful, for primitive data types like strings it will work greate, but i dont know how it behaves with nested object.

Benoit