title: How to repeatedly build a list each time the same script is called in php
body: <p>I would like to be able to build a list so that when my php script is called
  I should see one object added to the array when I call a second time I should see
  two objects then three e.t.c.</p>
  
  <p>My url is as follows:</p>
  
  <p><a href="http://localhost/router.php/forwardtoAdduser/avalue/lookingglass/email@hotmail.com" rel="nofollow noreferrer">http://localhost/router.php/forwardtoAdduser/avalue/lookingglass/email@hotmail.com</a></p>
  
  <p>and my router php file is as follows:</p>
  
  <pre><code>function forwardtoadduser ($urlParams) {
  
      $adminclass = new Admin();
  
  
      $user = new User();
  
      $user -&gt; username = $urlParams[3];
      $user -&gt; password = $urlParams[4];
      $user -&gt; emailaddress = $urlParams[5];
  
  
  
      $adminclass -&gt; adduser($user);
  
  
  }
  </code></pre>
  
  <p>My admin.php file is as follow:</p>
  
  <pre><code>class Admin {
  
      public $arr = array();
  
  function adduser($user)
    {
  
  
      //make a multidimensional array to reference the user id
      //as well as the user data
  
  
      $arr = (array)$this;
  
  
      array_push($arr, $user);
  
  
      //open a connection
  
  
      var_dump($arr);
  
      //var_dump($arr[0] -&gt; username);
  
  
    }
  </code></pre>
  
  <p>When I run the php script each time I only see one object to the list. I get:</p>
  
  <pre><code>array(2) { ["arr"]=&gt; array(0) { } [0]=&gt; object(User)#2 (3) { ["username"]=&gt; string(6) "avalue" ["password"]=&gt; string(12) "lookingglass" ["emailaddress"]=&gt; string(17) "email@hotmail.com" } }
  </code></pre>
  
  <p>and I should get e.g. if I ran the script twice:</p>
  
  <pre><code>array(2) { ["arr"]=&gt; array(0) { } [0]=&gt; object(User)#2 (3) { ["username"]=&gt; string(6) "avalue" ["password"]=&gt; string(12) "lookingglass" ["emailaddress"]=&gt; string(17) "email@hotmail.com" } }
  array(2) { ["arr"]=&gt; array(0) { } [0]=&gt; object(User)#2 (3) { ["username"]=&gt; string(6) "avalue" ["password"]=&gt; string(12) "lookingglass" ["emailaddress"]=&gt; string(17) "email@hotmail.com" } }
  </code></pre>
  
  <p>I am trying to call the script with some c# code.</p>
  
  <p>how do I achieve such an outcome?</p>