title: Use array_filter in GET
body: <p>I have some problems with <code>GET</code> request. This request has two parameters to filter:</p>
  
  <pre><code>$app-&gt;get('/api/v1/provider/{destination}/{weight}', function ($request, $response, $args) {
  
     $em = getEntityManager();
     $destination = $em-&gt;getRepository(Transport::class)-&gt;findByDestination($args['destination']);
     $weight = $em-&gt;getRepository(Transport::class)-&gt;findByWeight($args['weight']);
  
       $provider_filter = array_filter($destination, function ($data) {
          return $data-&gt;weight == $weight;    
      });
  
      return $response-&gt;withJson($provider_filter);
  });
  </code></pre>
  
  <p>For example , if I write <code>$dato-&gt;weight == 3</code> instead of <code>$dato-&gt;weight == $weight</code>, I get correct result. The problem is in the variable <code>$weight</code>, due to which  <code>$weight</code> I get the error: <code>Undefined variable: weight</code>. The variable  <code>$weight</code> is defined outside the array_filter. Nevertheless, if I defined <code>$weight</code> inside the array I can't get the weight because of the error: <code>Undefined variable: args</code>.</p>
  
  <p>Any idea?</p>