title: How to properly loop through array keys in PHP
body: <p>If I have an array with multiple keys and values, like this:</p>
  <pre><code>$array = array(
    'key1' =&gt; 'value1',
    'key2' =&gt; 'value2',
  );
  </code></pre>
  <p>Are there any best-practices on how to loop through an array when I only use the keys?</p>
  <p>Possible solution 1:</p>
  <pre><code>foreach(array_keys($array) as $array_key) {
    echo $array_key;
  }
  </code></pre>
  <p>Possible solution 2:</p>
  <pre><code>foreach($array as $array_key =&gt; $array_value) {
    echo $array_key;
  }
  </code></pre>
  <p>I can see the advantage in solution 1 as it doesn't include the unused variable <code>$array_value</code>. <strong>Is there a difference in performace (speed, memory allocation, etc.) between these two?</strong></p>