title: PHP foreach() with arrays within arrays?
body: <p>I want to call a function on each element in an array. This is obviously very easy with a <code>foreach()</code>, but where I start breaking down is when arrays contain arrays. Can someone help me out with a function that will execute some code for every key -> value pair from a set of arrays within arrays. The depth could, in theory, be infinite, but a good limit would be 3 iterations (array in array in array) if recursion couldn't work.</p>
  
  <p>An example array would be one taken from $_POST below:</p>
  
  <pre>
  Array
  (
      [languages] => Array
      (
          [0] => php
          [1] => mysql
          [2] => inglip
      )
  
      [rates] => Array
      (
          [incall] => Array
          (
              [1hr] => 10
          )
  
          [outcall] => Array
          (
              [1hr] => 10
          )
  
      )
  )
  </pre>
  
  <p>Just to make sure, what I want to do is run a piece of code (a function) that is passed every 'end node' in the array structure, so in the example above, it would be called when...</p>
  
  <pre>
  [0] => php
  [1] => mysql
  [2] => inglip
  [1hr] => 10
  [1hr] => 10
  </pre>
  
  <p>... is found.</p>
  
  <p>Thanks for any help,</p>
  
  <p>James</p>