title: looping through 2 array to find out which checkboxes should be checked
body: <p>I have 2 arrays, $categories_filters and $adds_filters. They both return results. When printed using print_r, they return data in following format:</p>
  
  <p>$categories_filters returns data like this:</p>
  
  <pre><code>Array
  (
  [0] =&gt; Array
      (
          [filterid] =&gt; 67
          [catid] =&gt; 1
          [filtername] =&gt; FILTERNAME1
          [sorder] =&gt; 1
          [visible] =&gt; 1
      )
  
  [1] =&gt; Array
      (
          [filterid] =&gt; 68
          [catid] =&gt; 1
          [filtername] =&gt; FILTERNAME155
          [sorder] =&gt; 2
          [visible] =&gt; 1
      )
      .....
  </code></pre>
  
  <p>$adds_filters returns the following:</p>
  
  <pre><code>  Array
  (
  [0] =&gt; Array
      (
          [addfilterid] =&gt; 9
          [addid] =&gt; 5
          [filterid] =&gt; 67
      )
  
  [1] =&gt; Array
      (
          [addfilterid] =&gt; 10
          [addid] =&gt; 5
          [filterid] =&gt; 163
      )
  
  )....
  </code></pre>
  
  <p>I am trying the following:
  I have checkbox for each value in the $categories_filters. If the filterid exists in the $adds_filters array, i want that checkbox to be checked, otherwise, i want that checkbox just to be displayed unchecked.</p>
  
  <p>I am trying to achieve that with the following code:</p>
  
  <pre><code>if($categories_filters) {
      foreach ($categories_filters as $key1=&gt;$value){
          echo "&lt;div class='chb_group'&gt;";
          echo "&lt;span class='custom_chb_wrapper'&gt;";
          foreach ($adds_filters as $key2=&gt;$af) {
              if($af['filterid'] == $value['filterid']) {
                  echo "&lt;input type='checkbox' name='categoriesfilters[]' id= '".$value['filterid']."'  value='" .$value['filterid'] ."'  checked = 'checked' class='zcheckbox' /&gt;";    
              } else  {
                  echo "&lt;input type='checkbox' name='categoriesfilters[]' id= '".$value['filterid']."'  value='" .$value['filterid'] ."' class='zcheckbox' /&gt;";
              }
          } 
          echo "&lt;label&gt;" .$value['filtername']. "&lt;/label&gt;";
          echo "&lt;/span&gt;";
          echo "&lt;/div&gt;"
      } 
  }else {
      echo  "No filters"; 
  }
  </code></pre>
  
  <p>Quick catchers will realize that I get 2 checkboxes displayed for each value in the arrays, instead of one (checked or unchecked)</p>
  
  <p>I guess that different approach is needed here.</p>