title: In PHP, how can I add an object element to an array?
body: <p>I'm using PHP. I have an array of objects, and would like to add an object to the end of it.</p>
  
  <pre><code>$myArray[] = null; //adds an element
  $myArray[count($myArray) - 1]-&gt;name = "my name"; //modifies the element I just added
  </code></pre>
  
  <p>The above is functional, but is there a cleaner and more-readable way to write that? Maybe one line?</p>