title: Set index of an array as a variable
body: <p>Sorry, but it might be a very simple answer. </p>
  
  <p>I do have an array: </p>
  
  <pre><code>Array ( [0] =&gt; 3 [1] =&gt; 0 )
  </code></pre>
  
  <p>If I do this:</p>
  
  <pre><code>foreach($array as $key){
      $index = $key;
      print_r($index);
  }
  </code></pre>
  
  <p>Of course I get:</p>
  
  <p>3</p>
  
  <p>0</p>
  
  <p>I want to have a variable with the index:</p>
  
  <p>0</p>
  
  <p>1</p>
  
  <p>How do I do it? It should be very simple. I am disparing! Thanks for help! </p>