title: PHP foreach loop inside foreach loop?
body: <p>I have two foreach loop. In first foreach loop menu list and second foreach loop is database fetch loop. So i want compare first foreach key to second foreach value first foreach array result is shown</p>
  
  <pre><code>   Array
  (
      [master/city] =&gt; City
      [master/national_holiday] =&gt; National Holiday
      [master/operator_comments] =&gt; Operator Comments
      [master/sensors] =&gt; Sensors
  )
  </code></pre>
  
  <p>and second foreach array result</p>
  
  <pre><code>   Array
          (
              [0] =&gt; Array
                  (
                      [menu_url] =&gt; monitoring/tickets
                      [menu_category] =&gt; monitoring
                      [read] =&gt; 1
                      [write] =&gt; 1
                  )
  
              [1] =&gt; Array
                  (
                      [menu_url] =&gt; monitoring/serach_tickets
                      [menu_category] =&gt; monitoring
                      [read] =&gt; 1
                      [write] =&gt; 1
                  )
  
              [2] =&gt; Array
                  (
                      [menu_url] =&gt; master/national_holiday
                      [menu_category] =&gt; monitoring
                      [read] =&gt; 1
                      [write] =&gt; 0
                  )
  )
  </code></pre>
  
  <p>I try to use this code but not working fine</p>
  
  <pre><code>   foreach( $first_array as $key =&gt; $value) {
  
    foreach( $second_array as $second ) {
      if ($second['value'] == $key) {
         echo "Hi";
      }
     }
  }
  </code></pre>
  
  <p>can you suggest what is my mistake.</p>
  
  <p>My real code using in view</p>
  
  <pre><code>&lt;?php
                      $i = 1;
  
                      foreach($first_array as $k =&gt; $val) {
                      ?&gt;
                      &lt;tr&gt;
                        &lt;td&gt;{{ $i }}&lt;/td&gt;
                        &lt;td class="mailbox-name"&gt;{{ $val }}&lt;/td&gt;
                      &lt;?php
                          foreach ($edit_rights['role_rights'] as $rights) {
                      ?&gt;                                           
                        &lt;td&gt;&lt;input type="checkbox" class="master_read" name="menu_master_read[]" &lt;?php if ($rights['menu_url'] == $k) { echo 'checked'; } else {echo ''; }?&gt; value="{{ $k }}"&gt;&lt;/td&gt;
                        &lt;td&gt;&lt;input type="checkbox" class="master_write" name="menu_master_write[]" value="{{ $k }}"&gt;&lt;/td&gt;
                      &lt;/tr&gt;
                       &lt;?php } $i++;  } ?&gt;
                      &lt;/tr&gt;
  </code></pre>