title: update a global array within a function
body: <p>I have a global array in which I am trying to update a value (remain persistent) and then display it.<br>
  I get no error but the array never gets updated.</p>
  
  <pre><code>&lt;?php
  $anchor = 'bird';
  $stuff = array('apple', 'bird', 'frog');
  
  function insert($anchor, $stuff){
      foreach($stuff as $part){
          $new_array = array($anchor =&gt; rand());
          if($part == $anchor){
              array_push($stuff, $new_array);
          }
      }
  }
  
  for($x = 0; $x &lt; 2; $x++){
      insert($anchor, $stuff);
      var_dump($stuff);
  }
  </code></pre>
  
  <p>output:</p>
  
  <pre><code>array(3) {
    [0]=&gt;
    string(5) "apple"
    [1]=&gt;
    string(4) "bird"
    [2]=&gt;
    string(4) "frog"
  }
  array(3) {
    [0]=&gt;
    string(5) "apple"
    [1]=&gt;
    string(4) "bird"
    [2]=&gt;
    string(4) "frog"
  }
  </code></pre>
  
  <p>expected output:</p>
  
  <blockquote>
    <p>{'bird' => 674568765}<br>
    {'bird' => 986266261}</p>
  </blockquote>
  
  <p>How do I update an array within a function, so that the changes are reflected globally (persistent)?</p>