title: array_splice() - Numerical Offsets of Associative Arrays
body: <p>I'm trying to do something but I can't find any solution, I'm also having some trouble putting it into works so here is a sample code, maybe it'll be enough to demonstrate what I'm aiming for:</p>
  
  <pre><code>$input = array
  (
      'who' =&gt; 'me',
      'what' =&gt; 'car',
      'more' =&gt; 'car',
      'when' =&gt; 'today',
  );
  </code></pre>
  
  <p>Now, I want to use <a href="http://php.net/manual/en/function.array-splice.php" rel="nofollow noreferrer"><code>array_splice()</code></a> to remove (and return) one element from the array:</p>
  
  <pre><code>$spliced = key(array_splice($input, 2, 1)); // I'm only interested in the key...
  </code></pre>
  
  <p>The above will remove and return 1 element (third argument) from <code>$input</code> (first argument), at offset 2 (second argument), so <code>$spliced</code> will hold the value <em><code>more</code></em>.</p>
  
  <p>I'll be iterating over <code>$input</code> with a foreach loop, I know the key to be spliced but the problem is I don't know its <strong>numerical offset</strong> and since <code>array_splice</code> only accepts integers I don't know what to do.</p>
  
  <p>A very dull example:</p>
  
  <pre><code>$result = array();
  
  foreach ($input as $key =&gt; $value)
  {
      if ($key == 'more')
      {
          // Remove the index "more" from $input and add it to $result.
          $result[] = key(array_splice($input, 2 /* How do I know its 2? */, 1));
      }
  }
  </code></pre>
  
  <p>I first though of using <a href="http://php.net/manual/en/function.array-search.php" rel="nofollow noreferrer"><code>array_search()</code></a> but it's pointless since it'll return the associative index....</p>
  
  <p><strong>How do I determine the numerical offset of a associative index?</strong></p>