title: how to build arrays of objects in PHP without specifying an index number?
body: <p>Here is a weird question. I am building an array of objects manually, like this:</p>
  
  <pre><code>$pages_array[0]-&gt;slug = "index";
  $pages_array[0]-&gt;title = "Site Index";  
  $pages_array[0]-&gt;template = "interior";
  
  $pages_array[1]-&gt;slug = "a";
  $pages_array[1]-&gt;title = "100% Wide (Layout A)";
  $pages_array[1]-&gt;template = "interior";
  
  $pages_array[2]-&gt;slug = "homepage";
  $pages_array[2]-&gt;title = "Homepage";
  $pages_array[2]-&gt;template = "homepage";
  </code></pre>
  
  <p>I like how clearcut this is, but because I have to specify the index number, I can't rearrange them easily. How can I do this without the index number? Related, what is a better way to do this?</p>
  
  <p>I also tried writing this by making a class, and having each spot on the array be instances of that class. But since this is a configuration file, it was hard to read and know what argument went with what parameter. That's why I chose this old-school method above.</p>
  
  <p>Any thoughts are much appreciated!</p>