title: Check if an array contains another array with PHP
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/12867315/checking-if-an-array-contains-all-elements-of-another-array">Checking if an array contains all elements of another array</a>  </p>
  </blockquote>
  
  
  
  <p>I have posted something like this to the Stackoverflow before, but the answers do not fully satisfy me. That's why I'm posting the question again, but changing the question all along.</p>
  
  <p>Some people helped me to construct a function that checks if an <code>array($GroupOfEight[$i])</code> that is an element of a multidimensional <code>array($GroupOfEight)</code> equals another array($stackArray), disregarding the number ordering in the arrays.</p>
  
  <p>However, what I need to check is whether the mentioned <code>array($stackArray)</code> contains any another <code>array($GroupOfEight[$i])</code> in the multidimensional <code>array($GroupOfEight)</code> or not, that means main <code>array($stackArray)</code> can consist more elements than <code>subarrays($GroupOfEight[$i])</code>.</p>
  
  <p>Here is the one working code that I've gathered so far, but need to be modified to the version I want:</p>
  
  <pre><code> &lt;?php
      $GroupOfEight = array (
                            array(0,1,3,2,4,5,7,6),
                            array(4,5,6,7,15,12,13,14),
                            array(12,13,15,14,8,9,11,10),
                            array(2,6,14,10,3,7,15,11),
                            array(1,3,5,7,13,15,9,11),
                            array(0,4,12,8,1,5,13,9),
                            array(0,1,3,2,8,9,11,10)
                  );
  
  
      $stackArray = array(0,4,12,1,9,8,5,13,9,2,5,2,10);
      /*$stackArray gets value with POST Method by URL parameter.
      This is just the example. As you see this array contains 
      $GroupOfEight[4], and also it contains many other numbers.*/
  
  
      /* The function given below checks if $stackArray equals any
      of the subarrays of $GroupOfEight. However, we want to check
      if $stackArray caontains any of the subarrays of function.
      If it does, function should return the index number, if it
      doesnt it should return -1.*/
      function searcheight($stackArray,$GroupOfEight){
          for($i=0; $i&lt;count($GroupOfEight);$i++){
  
  
    $containsSearch = (count(array_intersect($stackArray,$GroupOfEight[$i])) == count($stackArray) &amp;&amp; count(array_intersect($stackArray,$GroupOfEight[$i])) == count($GroupOfEight[$i]));
          if($containsSearch){
              return $i; //This specifies which index in GroupOfEight contains a matching array
          }
      }
      return -1;
  }
  
  // Calling the function that is given above.
  echo searcheight($stackArray,$GroupOfEight);
  ?&gt;
  </code></pre>
  
  <p>Any logical ideas or solutions will kindly be much appreciated. Thanks.</p>