Use json_encode() and json_decode()
json_decode() 's second parameter is set to TRUE.
Function definition:
That will convert your object into an associative array.
Reference:
https://stackoverflow.com/questions/34428702/convert-stdclass-object-to-associative-array-in-php/34428735#34428735
$arr = json_decode(json_encode($yourObject), TRUE);
json_decode() 's second parameter is set to TRUE.
Function definition:
mixed json_decode ( string $json [, bool $assoc = false [, int $depth > = 512 [, int $options = 0 ]]] )
That will convert your object into an associative array.
Reference:
https://stackoverflow.com/questions/34428702/convert-stdclass-object-to-associative-array-in-php/34428735#34428735
No comments:
Post a Comment