title: PHP - Check if values in one array exist in another array multi-dimensional array
body: <p>I have the following two arrays.</p>
  
  <p>This is a flat array (string: $second_names):</p>
  
  <pre><code>Array ( [0] =&gt; Cars [3] =&gt; Bikes [8] =&gt; Trucks ) //$second_names
  </code></pre>
  
  <p>I have this multidimensional array - (string: $premiumCatArraySets):</p>
  
  <pre><code>Array
  (
      [0] =&gt; Array
          (
              [primary-category] =&gt; Automobiles
              [secondary-category] =&gt; Cars
              [tertiary-category] =&gt; Fiat Punto
          )
  [1] =&gt; Array
      (
          [primary-category] =&gt; Automobiles
          [secondary-category] =&gt; Cars
          [tertiary-category] =&gt; BMW
      )
  
  [2] =&gt; Array
      (
          [primary-category] =&gt; Automobiles
          [secondary-category] =&gt; Bikes
          [tertiary-category] =&gt; Honda
      )
  
  [4] =&gt; Array
      (
          [primary-category] =&gt; Automobiles
          [secondary-category] =&gt; Trucks
          [tertiary-category] =&gt; Iveco
      )
  
  [6] =&gt; Array
      (
          [primary-category] =&gt; Automobiles
          [secondary-category] =&gt; Cars
          [tertiary-category] =&gt; Mercedes
      )
  
  [9] =&gt; Array
      (
          [primary-category] =&gt; Automobiles
          [secondary-category] =&gt; Cars
          [tertiary-category] =&gt; Toyota
      )
  </code></pre>
  
  <p>I am trying to use <code>in_array</code> to see whether the values in the flat array exist and output the brand of the car.</p>
  
  <p>This is what I tried</p>
  
  <pre><code>foreach ($second_names as $second_name) {//Vechile type e.g. car, truck, bike
      if(in_array($second_name, $premiumCatArraySets)){
          echo '&lt;h2&gt;'.$second_name.'&lt;/h2&gt;';
          foreach ($third_names as $third_name) {// e.g. Fiat, BMW, Toyota
              echo $third_name.'&lt;br/&gt;';
          }
      }
  }
  </code></pre>
  
  <p>The line for <code>if(in_array($second_name, $premiumCatArraySets)){</code> doesn't seem to be displaying anything.</p>