matching array string values in nested for loop in PHP doesn't recognize condition
<p>I am trying to strip out string values from <code>array $error_message_key</code> that match string values from <code>array $err_strings</code>. And then assign the strings that are left to <code>$postback</code>. The particular code that does the filtering in the function below is <code>if($error_message_key[$e] != $err_strings[$g])</code> but it doesn't seem to work. I still get all the string values from <code>array $error_message_key</code>.</p>

<pre><code>$err_strings = explode('+', $catch_value);

for($e = 0; $e &lt; count($error_message_key); ++$e)
  {
   for($g = 0; $g &lt; count($err_strings)-1; ++$g)
   {
    if($error_message_key[$e] != $err_strings[$g])
    { 
     $postback .= '&amp;'.$error_message_key[$e].'='.$_POST[$error_message_key[$e]]; 
    }
   }
  }
</code></pre>

<p><strong>UPDATE</strong>: Here are the arrays:</p>

<pre><code>$error_message_key = array('email','firstName','lastName','pwd','username','phone','street','city', 'country', 'postal','province');

$err_strings = array('lastName','pwd','username');
</code></pre>

<p>Array  <code>$err_strings</code> actually comes from <code>explode</code>'d string <code>$catch_value</code> which is in a form of <code>"lastName+pwd+firstName+"</code>.</p>

<p><strong>UPDATE:</strong></p>

<p>The output should be in a form of: </p>

<pre><code>$postback = 'lastName=value&amp;firstName=value&amp;phone=value&amp;....'
</code></pre>

<p><strong>UPDATE:</strong>
This is actually a script that responds if a user has wrong inputs in the form. The supposed to be stripped out string are names of the  fields which would have the border color changed. The remaining string values are also names of the  fields with correct inputs which would then be refilled with the same inputs... Please feel free to suggest another way of doing this if you think it's inappropriate...</p>
