Convert Object to Array in PHP
There are quite a few ways to do this and each of them has its strengths and weaknesses. Find out if one suits your needs by trying one of the approaches below. Casting with (array) $array = (array) $obj; Problem is this doesn’t convert complex / multi-dimensional objects well. get_object_vars() $array = get_object_vars( $obj ); …