title: How to access array values outside for loop in PHP
body: <p>I'm working with array in PHP. My question is how to access PHP array values outside the for loop.</p>
  
  <p>Here is the code.</p>
  
  <pre><code>&lt;?php
  $a = array("1","2");
  for($i=0;$i&lt;count($a);$i++){
  #some core functionality DB related.
  $val = $row['values'];
  $b = explode(',',$val);
  }
  print_r($b);
  
  $fin = array_combine($a,$b);
  print_r($fin);
  ?&gt;
  </code></pre>
  
  <p>I want to combine both the array, but I'm not getting array <code>b</code>. How to access the array values outside for loop?</p>
  
  <p>Expected output:</p>
  
  <pre><code>Array ( [0] =&gt; 7 [1] =&gt; 6 ) // b array
  Array ( [1] =&gt; 7 [2] =&gt; 6 ) // fin array
  </code></pre>