How do closures work in PHP (If at all)?
<pre><code>function outer_function() {
  $nid = 3;

    function exists($var) {
    print $nid;
    return $var-&gt;nid == $nid;
    }   

    $a_filtered_array = array_filter($an_array, "exists");
}
</code></pre>

<p>I'm trying to filter this array using a variable that's defined in the outer function, but the variable is not defined. This would work in JS. What am I doing wrong here? How would I accomplish this in PHP?</p>
