I've recently ran into an issue where I had to convert an object that functions as a model (enforcing datatypes and such) into an array for further processing. At least the public and private properties have to show up.
Looking on stack overflow, I've found various methods to do so, however most only worked for single dimensions (no nested models), while the multidimensional versions always left the full model name in array keys.
How can I get this done while keeping the code clean?
Edit: Since someone marked this as duplicate, it's not. The 2 issues linked as duplicate (one that I even referred to myself) are not the same as they either don't work for multidimensional objects, or keep array keys including the class name prefixed to the property name. I've tested both of those solutions in my search, and neither did exactly what I described.