php sort properties of object
- by lannoo
I want to sort the properties of an object so I can loop through them in a defined order.
for example: I have an object 'book' with the following properties: 'id', 'title', 'author', 'date'.
Now i want to loop through these properties like this:
foreach($book as $prop=>$val)
//do something
now the order of the loop has to be 'title', then 'author', 'date' and 'id'
How would one do this?
(I can't change the order of the properties in the class of the object because there arent any properties defined there, I get the object from the database with 'MyActiveRecord')