If your object has only public fields, then converting the the object with $arr = (array) $object is the easier way. But when some values can only be reached with getters or if your fields are private or protected (as they should be in good design) then a simple array conversion will not work.
Easier, but not universal
If your object has only public fields, then converting the the object with
$arr = (array) $objectis the easier way. But when some values can only be reached with getters or if your fields are private or protected (as they should be in good design) then a simple array conversion will not work.