title: Iterate through an array in PHP
body: <p>I'm very new to PHP but I have to make something quickly.</p>
  
  <pre><code> $fql = "SELECT uid, name, pic_square, sex 
           FROM user 
           WHERE uid IN (SELECT uid2 FROM friend WHERE uid1 = me())";
  
        $response = $facebook-&gt;api(array(
             'method' =&gt; 'fql.query',
             'query' =&gt;$fql,
           ));
  
      $allUsers = $mapper-&gt;getAll();
  </code></pre>
  
  <p>So I've got $response and, for example, <code>$response[0]["name"]</code> returns the name of the first user and <code>$response[0]["id"]</code> returns the id of the first user.</p>
  
  <p>Then I've got the $allUsers array in which I've got all of the users ids. For <code>$allUsers[0]-&gt;id</code> returns the id of the first user.</p>
  
  <p>Ok, now as the result I would like to filter the $response array and have in it only users whose id is present in $allUsers array. It may be new array, for example $filteredResponse.</p>
  
  <p>Thank you very much for the help, it's really just an issue of me not really knowing the syntax</p>
  
  <p>I wrote sth like this:</p>
  
  <pre><code>$filteredResult = array();
  
      foreach ($response as &amp;$userfb) {
          foreach($allUsers as &amp;$userdb){
              if($userfb["id"] == $userdb-&gt;id){
                  array_push($filteredResult, $userfb);
                  break 1;
              }
          }
      }
  </code></pre>
  
  <p>Is this correct ?</p>