I need to transform an object into an array so I can navigate through it and extract its data, even with:
$array = (array) $object;
But the result with a var_dump($array)
is as follows, so I can not traverse it with a foreach :
array(1) {
["Clientedata"]=>
array(3) {
["nome"]=>
string(4) "Nome"
["email"]=>
string(19) "[email protected]"
["celular"]=>
string(15) "(00) 00000-0000"
}
}
I want to loop through the array as follows:
foreach($array as $key => $value){
echo "$key: $value";
}
So I just get an error: Notice: Array to string conversion in ...
And return: Clientedata: Array