Convert stdClass object to array in PHP

Convert stdClass object to array in PHP
The easiest way is to JSON-encode your object and then decode it back to an array:
$array = json_decode(json_encode($object), True);
Or if you prefer, you can traverse the object manually, too:
foreach ($object as $value)
    $array[] = $value->post_id;
Please follow and like us:
0