title: php: display key and value for each element of associative array
body: <p>The following php snippet will display both the key and the value of each element in an associative array $ar. However, couldn't it be done in a more elegant way, such that the key and the value pointers are advanced by the same mechanism? I still would like it to be executed in a <code>foreach</code> loop (or some other that does not depend on knowledge of the number of elements).</p>
  
  <pre><code>&lt;?php
  $ar = array("A" =&gt; "one", "B" =&gt; "two", "C" =&gt; "three");
  foreach($ar as $a){
      echo "key: ".key($ar)." value: ".$a."\n";
      $ignore = next($ar);//separate key advancement - undesirable
  }
  ?&gt;
  </code></pre>