I am wondering if there is a built-in way in PHP to cast multidimensional objects to arrays?
The problem is when applying a regular casting on an object, the first dimension only is being affected, all other dimensions remind the same.
Note: I am interested in casting only!
Example:
$a = new stdClass();
$a->b = 'qwe';
$a->c = new stdClass();
$a->c->d = 'asd';
var_dump((array)$a); // echoes:
array(2) {
["b"]=>
string(3) "qwe"
["c"]=>
object(stdClass)#2 (1) {
["d"]=>
string(3) "asd"
}
}
As you can see only the first dimension was affected, so how to cast multidimensional objects?