title: PHP: Get key from array?
body: <p>I am sure that this is super easy and built-in function in PHP, but I have yet not seen it.</p>
  
  <p>Here's what I am doing for the moment:</p>
  
  <pre><code>foreach($array as $key =&gt; $value) {
      echo $key; // Would output "subkey" in the example array
      print_r($value);
  }
  </code></pre>
  
  <p>Could I do something like the following instead and thereby save myself from writing "$key => $value" in every foreach loop? (psuedocode)</p>
  
  <pre><code>foreach($array as $subarray) {
      echo arrayKey($subarray); // Will output the same as "echo $key" in the former example ("subkey"
      print_r($value);
  }
  </code></pre>
  
  <p>Thanks!</p>
  
  <p>The array:</p>
  
  <pre><code>Array
  (
      [subKey] =&gt; Array
          (
              [value] =&gt; myvalue
          )
  
  )
  </code></pre>