i have:
stdClass Object
(
[0] => stdClass Object
(
[one] => aaa
[two] => sss
)
[1] => stdClass O
Cast it to an array:
$array = (array)$stdClass;
Essentially, just type cast it:
$arr = (array)$obj;
$var = $arr[0];
But read the caveats here.
If you have an nested array you can used json_encode
and json_decode
to convert the whole object to an array:
$result = json_decode(json_encode($source), JSON_OBJECT_AS_ARRAY);
Cast it
$array = (array) $stdObject;
Cast it into an array. Currently it is not readable to PHP as an array.
$array = (array)$stdClass;