Converting stdClass object to PHP array

#Converting stdClass object to PHP array


The easiest way is to JSON-encode your object and then decode it back to an array:

$array = json_decode(json_encode($stdclassobject), True);

Or you can also traverse the object using loop, too:
foreach ($stdclassobject as $value) 

$array[] = $value->post_id;

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.