title: How to compare values from 2 arrays and return true if all conditions are true
body: <p>I have 10 students ID's with each <code>sub1</code> and <code>sub2</code> that defines which subjects they are enrolled in, in the <code>$result</code> array variable below</p>
  
  <pre><code>Array ( 
  [0] =&gt; Array ( [sub1] =&gt; BIO [sub2] =&gt; ) 
  [1] =&gt; Array ( [sub1] =&gt; BIO [sub2] =&gt; ) 
  [2] =&gt; Array ( [sub1] =&gt; MATH [sub2] =&gt;CHEM ) 
  [3] =&gt; Array ( [sub1] =&gt; MATH [sub2] =&gt; BIO ) 
  [4] =&gt; Array ( [sub1] =&gt; PHY [sub2] =&gt; ) 
  [5] =&gt; Array ( [sub1] =&gt; ELCT [sub2] =&gt; ) 
  [6] =&gt; Array ( [sub1] =&gt; SOC [sub2] =&gt; GEO) 
  [7] =&gt; Array ( [sub1] =&gt; HIS [sub2] =&gt; ) 
  [8] =&gt; Array ( [sub1] =&gt; ART [sub2] =&gt; BIO ) 
  [9] =&gt; Array ( [sub1] =&gt; PHY [sub2] =&gt; HIS ) 
  )
  </code></pre>
  
  <p>and another <code>$subjects</code> variable containing the subject that each student should be enrolled in</p>
  
  <pre><code> Array ( 
      [student1sub] =&gt; BIO 
      [student2sub] =&gt; MATH 
      [student3sub] =&gt; CHEM 
      [student4sub] =&gt; PHYS
      [student5sub] =&gt; ELCT 
      [student6sub] =&gt; ECO 
      [student7sub] =&gt; SOC 
      [student8sub] =&gt; GEO 
      [student9sub] =&gt; HIS 
      [student10sub] =&gt; ART 
      )
  </code></pre>
  
  <p>I need to check if each student is enrolled in a the according subject that he should be enrolled in from the condition in <code>$subjects</code> by checking their <code>sub1</code> and <code>sub2</code> in the <code>$result</code> array</p>
  
  <p>I read that I should use <code>in_array</code> but not sure how to implement it to loop over each student <code>sub1</code> and <code>sub2</code></p>
  
  <pre><code>if (in_array("BIO", $subject))
    {
      return true;
    }
  else
    {
      return false;
    }
  </code></pre>
  
  <p>if all 10 students from <code>$result</code> meet its conditions then I need to show a success msg if not show an error msg</p>
  
  <p><strong>what i am trying to achieve | expected output</strong></p>
  
  <p>find the sub from <code>[student1sub]</code> in <code>[0] =&gt; Array ( [sub1] =&gt; BIO [sub2] =&gt; )</code> </p>
  
  <p>find the sub from <code>[student2sub]</code> in <code>[1] =&gt; Array ( [sub1] =&gt; BIO [sub2] =&gt; )</code></p>
  
  <p>find the sub from <code>[student3sub]</code> in <code>[2] =&gt; Array ( [sub1] =&gt; MATH [sub2] =&gt;CHEM )</code> </p>
  
  <p>find the sub from <code>[student4sub]</code> in <code>[3] =&gt; Array ( [sub1] =&gt; MATH [sub2] =&gt; BIO )</code></p>
  
  <p>find the sub from <code>[student5sub]</code> in <code>[4] =&gt; Array ( [sub1] =&gt; PHY [sub2] =&gt; )</code> </p>
  
  <p>find the sub from <code>[student6sub]</code> in <code>[5] =&gt; Array ( [sub1] =&gt; ELCT [sub2] =&gt; )</code></p>
  
  <p>find the sub from <code>[student7sub]</code> in <code>[6] =&gt; Array ( [sub1] =&gt; SOC [sub2] =&gt; GEO)</code> </p>
  
  <p>find the sub from <code>[student8sub]</code> in <code>[7] =&gt; Array ( [sub1] =&gt; HIS [sub2] =&gt; )</code></p>
  
  <p>find the sub from <code>[student9sub]</code> in <code>[8] =&gt; Array ( [sub1] =&gt; ART [sub2] =&gt; BIO )</code> </p>
  
  <p>find the sub from <code>[student10sub]</code> in <code>[9] =&gt; Array ( [sub1] =&gt; PHY [sub2] =&gt; HIS )</code></p>