title: php sort properties of object
body: <p>I want to sort the properties of an object so I can loop through them in a defined order.</p>
  
  <p>for example: I have an object 'book' with the following properties: 'id', 'title', 'author', 'date'.</p>
  
  <p>Now i want to loop through these properties like this: </p>
  
  <pre><code>foreach($book as $prop=&gt;$val)
  //do something
  </code></pre>
  
  <p>now the order of the loop has to be 'title', then 'author', 'date' and 'id'</p>
  
  <p>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')</p>