title: PHP array_push incorrectly pushing data
body: <p>I am trying to push an altered array to a class member, but for some reason it's just replacing the first element with the second.</p>
  
  <pre><code>class Registration {
    var $formID;
    var $formKeys;
    var $registrations = array();
  
    function __construct($a) {
      $this-&gt;formID = $a;
  
      global $wpdb;
      $keys = $wpdb-&gt;get_results('SELECT * FROM wp_nf3_fields WHERE parent_id = '.$a);
  
      $labels = array();
  
      foreach($keys as $key) {
        $labels['_field_'.$key-&gt;id] = $key-&gt;label;
      }
  
      $this-&gt;formKeys = $labels;
  
    }
  
    function get_registrations() {
      global $wpdb;
  
      // Get IDs of fields
      $IDs = $wpdb-&gt;get_results('SELECT wp_posts.ID FROM wp_posts JOIN wp_postmeta ON wp_postmeta.post_id = wp_posts.ID WHERE wp_posts.post_type = "nf_sub" AND wp_postmeta.meta_key = "_form_id" AND wp_postmeta.meta_value = "'.$this-&gt;formID.'"');
  
      foreach ($IDs as $id) {
        $id = $id-&gt;ID;
  
        $regs = $wpdb-&gt;get_results('SELECT * FROM `wp_postmeta` WHERE wp_postmeta.post_id = '.$id);
  
        $events = unserialize($regs[8]-&gt;meta_value);
  
        $numberOfEvents = count($events);
  
        $tempEvent = "";
  
        foreach($events as $key =&gt; $value) {
          array_push($this-&gt;registrations, $regs);
  
          $this-&gt;registrations[count($this-&gt;registrations)-1][8]-&gt;meta_value = $events[$key];     
  
        }
  
      }
  
      $registrations = $this-&gt;clean_up_data($this-&gt;registrations);
  
      return $registrations;
    }
  }
  </code></pre>
  
  <p>You can see what it returns at this URL. <a href="https://www.ulmaonline.com/tournament/tournament-information/" rel="nofollow noreferrer">https://www.ulmaonline.com/tournament/tournament-information/</a></p>
  
  <p>I know I have to be missing something very simple. But I just can't seem to find it.</p>