Convert stdClass object to array in PHP - Stack Overflow

PHOTO EMBED

Tue Oct 25 2022 11:32:18 GMT+0000 (Coordinated Universal Time)

Saved by @kalehm #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;
content_copyCOPY

https://stackoverflow.com/questions/19495068/convert-stdclass-object-to-array-in-php