title: Declaring a global array
body: <p>Hi. I recently learned PHP and am trying to declare a global array so I can access inside a function. But I seem to be missing something because I get the error 'Undefined variable:' </p>
  
  <p>Here is my code:</p>
  
  <pre><code>global $second_array;
  $second_array = array();
  
  function operatii($v) {
    $var1 = $second_array[count($second_array)-1];
    $var2 = $second_array[count($second_array)-2];
    $rez = null;
  
    echo $var1 . $var2 . "este?";
  }
  
  for ($i = 0; $i &lt; count($a); $i++){
    if ($a[$i] === "+" || $a[$i] === "-" || $a[$i] === "*" || $a[$i] === "/" ) {
      operatii($a[$i]);
    } else {
      array_push($second_array, $a[$i]);
    }
  }
  </code></pre>
  
  <p>I seem to be able to use the <code>$second_array</code> in the for loop, but can't use it in the operatii function.<br>
  How can I solve this problem?</p>