Filtering a Multidimensional Array based on User Input
<p>I found an excellent tutorial on how to filter a Multidimensional array here:
<a href="http://stackoverflow.com/questions/7341033/php-filter-2-dimensional-array-by-specific-key">PHP filter 2 dimensional array by specific key</a></p>

<p>While </p>

<pre><code>$filtered = array_filter(
    $array, 
    function($v) { 
        return $v['type'] == 'folder'; 
    }
); 
</code></pre>

<p>does do exactly what I need in terms of only displaying the folder entries, I need to be able to filter the array based on user input.</p>

<p>So from the example used on the page I lised above, there would be a checkbox for folder, and for page, then depending on what the user chooses (page, folder, or both), their selection would be displayed.</p>

<p>The problem I am running into is that I can't seem to use a variable to store $v['type'] == 'folder'.</p>

<p>I am hoping to do something like:</p>

<pre><code>$filtered = array_filter($array, function($v) { return $userSelections; });
</code></pre>

<p>I also explored the possibility of using eval() (I know it may not be the best idea, but I've tried everything else I can think of) to provide the contents of the variable, but that doesn't seem to work either.</p>

<p>Any advice here would be great.</p>

<p>Thanks.</p>
