Passing Function Arguments to an Inner Function?
<p>I am trying to create a function to initiate date_compare() which is a <code>usort</code> function for a specific array and key.</p>

<pre><code>function init_date_compare($key, $array) {
    $key2 = $key;
    function date_compare($a, $b) {
        global $key2;
        $t1 = strtotime($a[$key2]); $t2 = strtotime($b[$key2]);
        return $t2 - $t1;
    }
    usort($array, "date_compare");
}
$arr = array(array("Aug-2-2012"), array("June-2-2012"));
$arr = init_date_compare(0, $arr);
print_r($arr);
</code></pre>

<p>This outputs:</p>

<pre><code>Notice: Undefined index: in...
</code></pre>

<p>(So basically null, the scoping did not work).</p>

<p>I am not sure how scoping works with functions inside functions, but if I remember right, it is possible. I tried throwing in some <code>global</code>s and initializing <code>$key2</code> but I am unable to get this to work.</p>
