title: How to access the Variable in inner function PHP?
body: <p>How to access the variable in <code>inner</code> function of <code>outer</code> function variable?</p>
  
  <p>I want to access <code>$arr</code> variable in the inner function.</p>
  
  <pre><code>&lt;?php
  
  function outer() {
  
      $arr = array();
  
      function inner($val) {
  
          global $arr;
  
          if($val &gt; 0) {
              array_push($arr,$val);
          }
      }
  
      inner(0);
      inner(10);
      inner(20);
  
      print_r($arr);
  
  }
  
  outer();
  </code></pre>
  
  <p><strong><a href="http://codepad.org/RnTUSguR" rel="nofollow">codepad link</a></strong></p>