title: How can I write in PHP a function that modifies an array?
body: <p>I would like to have a function that takes an array as input and changes some values of the array (in my case the array is $_SESSION but I think it does not really maters).</p>
  
  <p>How can I do that?</p>
  
  <hr>
  
  <p><strong>ADDED</strong></p>
  
  <p>It sounds trivial. But it is not. I just want to set certain values to the array. For example, I want my function to change $_SESSION['x'] and $_SESSION['y']. As far as I know, if i pass an array as an argument, then any changes of the argument will not modify the original array. For example:</p>
  
  <pre><code>function change_array($x) {
     $x[0] = 100;
  }
  $x = array(1,2,3);
  change_array($x);
  </code></pre>
  
  <p>It will not change the $x.</p>
  
  <hr>
  
  <p><strong>ADDED 2</strong></p>
  
  <p>Why my question is down-voted? I think that the question is not so trivial in spite on the fact that it is short. I also think that I gave all relevant detail. As far as I realized (thanks to one answer) it is about "passing a reference". Moreover, the fact that I want to modify $_SEESION array makes it is a bit different.</p>