title: Best way to compare key and value of array(s) in Laravel
body: <p>Currently I have two arrays as shown in the picture below. What is the best way to compare them? Either by combining them together and compare within one array or compare the way I did?</p>
  
  <p><strong>$array1</strong></p>
  
  <p><a href="https://i.stack.imgur.com/vQDj3.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/vQDj3.png" alt="$array1"></a></p>
  
  <p><strong>$array2</strong></p>
  
  <p><a href="https://i.stack.imgur.com/Of8Wd.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Of8Wd.png" alt="enter image description here"></a></p>
  
  <p>This is what i did to compare them</p>
  
  <pre><code>&lt;table&gt;
  &lt;thead&gt;&lt;tr&gt;&lt;td&gt;status&lt;/td&gt;&lt;/tr&gt;&lt;/thead&gt;
  
  &lt;tbody&gt;
      &lt;tr&gt;
          &lt;td&gt;
              foreach($array1 as $key =&gt; $value)
              {
                  foreach($array2 as $ke2 =&gt; $value2)
                  {
                      if($value[0] == $value2[0] &amp;&amp; 
                          $value[1] == $value2[1] &amp;&amp; 
                          $value[2] == $value2[2])
                          YES
                      else
                          NO
                  }
              }
          &lt;/td&gt;
      &lt;tr&gt;
  &lt;/tbody&gt;
  &lt;/table&gt;
  </code></pre>
  
  <p><strong>updated</strong></p>
  
  <pre><code>&lt;table&gt;
  &lt;thead&gt;&lt;tr&gt;&lt;td&gt;status&lt;/td&gt;&lt;/tr&gt;&lt;/thead&gt;
  
  &lt;tbody&gt;
      &lt;tr&gt;
          &lt;td&gt;
              @foreach ($array1 as $key =&gt; $value)
                @if (isset($array2[$key]) &amp;&amp; $value == $array2[$key])
                  Yes
                @else
                  No
                @endif
              @endforeach
          &lt;/td&gt;
      &lt;tr&gt;
  &lt;/tbody&gt;
  &lt;/table&gt;
  </code></pre>
  
  <p><strong>but this display in the table like this</strong></p>
  
  <p>Status</p>
  
  <p>NoYesYes</p>
  
  <p>NoYesYes</p>
  
  <p>NoYesYes</p>
  
  <p><strong>Suppose to be</strong></p>
  
  <p>Status</p>
  
  <p>No</p>
  
  <p>Yes</p>
  
  <p>Yes</p>