title: PHP Cleaning up nested arrays with unknown structure
body: <p>Let's assume I have an array like so:</p>
  
  <pre><code>[1=&gt;[1=&gt;2,2=&gt;"something"],2=&gt;[1,2],3=&gt;"hello"]
  </code></pre>
  
  <p>The array has a "unorganized" structure with subarrays other values. </p>
  
  <p>I want to run a <code>htmlentities</code> function on each value to make sure nothing bad is inside the values. </p>
  
  <p>I've been reading up on <code>RecursiveIteratorIterator</code> but I cannot find an example of how to use it to apply a <strong>function</strong> to each value in a quite random nested multidimensional array. Any help is appreciated. </p>