I am trying to strip out string values from array $error_message_key that match string values from array $err_strings. And then assign the strings that are left to $postback. The particular code that does the filtering in the function below is if($error_message_key[$e] != $err_strings[$g]) but it doesn’t seem to work. I still get all the string values from array $error_message_key.
$err_strings = explode('+', $catch_value);
for($e = 0; $e < count($error_message_key); ++$e)
{
for($g = 0; $g < count($err_strings)-1; ++$g)
{
if($error_message_key[$e] != $err_strings[$g])
{
$postback .= '&'.$error_message_key[$e].'='.$_POST[$error_message_key[$e]];
}
}
}
UPDATE: Here are the arrays:
$error_message_key = array('email','firstName','lastName','pwd','username','phone','street','city', 'country', 'postal','province');
$err_strings = array('lastName','pwd','username');
Array $err_strings actually comes from explode‘d string $catch_value which is in a form of "lastName+pwd+firstName+".
UPDATE:
The output should be in a form of:
$postback = 'lastName=value&firstName=value&phone=value&....'
UPDATE:
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…