title: Loop through one array and find value in a subarray of a different multidimensional array
body: <p>I'm beating my head against the wall on this!</p>
  
  <p>I have two arrays:</p>
  
  <pre><code>$questionArray = Array(
      [0] =&gt; Array
          (
              [QueID] =&gt; 53
              [QueType] =&gt; Map question
              [QueText] =&gt; Where do you live?
          )
      [1] =&gt; Array
          (
              [QueID] =&gt; 55
              [QueType] =&gt; Multi selection
              [QueText] =&gt; What's your favorite car?
          )
      [2] =&gt; Array
          (
              [QueID] =&gt; 59
              [QueType] =&gt; Multi selection
              [QueText] =&gt; What's your favorite fruit?
          )
      [3] =&gt; Array
          (
              [QueID] =&gt; 54
              [QueType] =&gt; Single selection
              [QueText] =&gt; What's your favorite color?
          )
  )
  
  $answerArray = Array(
      [52264f64c9482] =&gt; Array
          (
              [0] =&gt; Array
                  (
                      [QueID] =&gt; 53
                      [QueType] =&gt; Map question
                      [Lat] =&gt; 41.86
                      [Lng] =&gt; -87.77
                      [AnsText] =&gt; 
                  )
              [1] =&gt; Array
                  (
                      [QueID] =&gt; 55
                      [QueType] =&gt; Multi selection
                      [Lat] =&gt; 
                      [Lng] =&gt; 
                      [AnsText] =&gt; Chevy
                  )
              [2] =&gt; Array
                  (
                      [QueID] =&gt; 54
                      [QueType] =&gt; Single selection
                      [Lat] =&gt; 
                      [Lng] =&gt; 
                      [AnsText] =&gt; Green
                  )
          )
      [522a522e9f41f] =&gt; Array
          (
              [0] =&gt; Array
                  (
                      [QueID] =&gt; 53
                      [QueType] =&gt; Map question
                      [Lat] =&gt; 51.41
                      [Lng] =&gt; -27.21
                      [AnsText] =&gt; 
                  )
              [1] =&gt; Array
                  (
                      [QueID] =&gt; 55
                      [QueType] =&gt; Multi selection
                      [Lat] =&gt; 
                      [Lng] =&gt; 
                      [AnsText] =&gt; Ford
                  )
              [2] =&gt; Array
                  (
                      [QueID] =&gt; 59
                      [QueType] =&gt; Multi selection
                      [Lat] =&gt; 
                      [Lng] =&gt; 
                      [AnsText] =&gt; Banana
                  )
          )
      [522a527ec0115] =&gt; Array
          (
              [0] =&gt; Array
                  (
                      [QueID] =&gt; 54
                      [QueType] =&gt; Single selection
                      [Lat] =&gt; 
                      [Lng] =&gt; 
                      [AnsText] =&gt; Blue
                  )
          )
  )
  </code></pre>
  
  <p>I am trying to loop through each array in $answerArray and then for each question array in $questionArray display the answer if there is one in a subarray of the $answerArray or if there is no matching answer in a subarray of the $answerArray return a "No answer" value. So if the script worked it would take the two arrays above and return:</p>
  
  <p>Where do you live?:<br>
      Lat - 41.86<br>
      Lng - -87.77<br>
  What's your favorite car? - Chevy<br>
  What's your favorite fruit? - No Answer<br>
  What's your favorite color? - Green  </p>
  
  <p>Where do you live?:<br>
      Lat - 51.41<br>
      Lng - -27.21<br>
  What's your favorite car? - Ford<br>
  What's your favorite fruit? - Banana<br>
  What's your favorite color? - No Answer  </p>
  
  <p>Where do you live?:<br>
      Lat - No Answer<br>
      Lng - No Answer<br>
  What's your favorite car? -  No Answer<br>
  What's your favorite fruit? - No Answer<br>
  What's your favorite color? - Blue  </p>
  
  <p>I'm getting nowhere, the closest i've managed is:</p>
  
  <pre><code>foreach ($answerArray as $ansArray) {
      foreach ($questionArray as $queArray) {
          foreach ($ansArray as $ansItemArray) {
              if ($ansItemArray['QueID'] == $queArray['QueID']) {
                  $result = $ansItemArray;
                  if ($result['SQueType']== 'Map question') {
                      echo $ansItemArray['QueText'].' - '.$result['Lat'].'&lt;/br&gt;';
                      echo $ansItemArray['QueText'].' - '.$result['Lng'].'&lt;/br&gt;';
                  } else {
                      echo $ansItemArray['QueText'].' - '.$result['AnsText'].'&lt;/br&gt;';
                  }
              } else {
                  $result = array();
                  if ($result['SQueType']== 'Map question') {
                      echo $ansItemArray['QueText'].' - No Answer&lt;/br&gt;';
                      echo $ansItemArray['QueText'].' - No Answer&lt;/br&gt;';
                  } else {
                      echo $ansItemArray['QueText'].' - No Answer&lt;/br&gt;';
                  }
              }
          }
      }
      echo '&lt;/br&gt;&lt;/br&gt;';
  }
  </code></pre>
  
  <p>Any help would be hugely appreciated.</p>