PHP – Convert stdClass object to array

The easiest way is to JSON-encode your object and then decode it back to an array: $array = json_decode(json_encode($object), True); you can traverse the object manually, too: foreach ($object as $value)      $array[] = $value->post_id;