PHP Last variable in nested foreach loop not showing when echoed
<p>Here is my code:</p>

<pre><code>$criterias = $_POST['criteria'];
$criteriaValue = $_POST['criteriaValue'];
$comments = $_POST['Comments'];

foreach ($criteriaValue as $key =&gt; $value ){
  foreach( $criterias as $criteriaValue ){
    if( $criteriaValue == $key ){
      $string1 = $key;
      //echo $string1;
      foreach( $comments as $comment =&gt; $comm ){
        if( $string1 == $comment ){
          $string3 = $comm;
          //echo $string3;
        }
      }
    }
  }
  foreach ( $value as $result ){
    $string2 = $result;
    //echo $string2;
  }
  $criteria .= mysql_real_escape_string( $string1 . '|' . $string2 . '|' . $string3 . '|' );
}
echo $criteria;
</code></pre>

<p>$criteria will echo string1 and string2.  But string3 is blank.  When I echo from within the foreach loop $string 3 shows the value.</p>

<p>I really appreciate everyone's help!!  I think this is probably simmple but I have beaten my head.</p>
