Can anyone tell me how to break a string apart so I can evaluate certain parts of it?
I am trying to take a string similar to this one "Y:3585460f5bc4f800:NYZS:093250860081744XF3LW 01:" and break it apart to evaluate the letters NYZS in the middle. I have the string stored in the variable $AVSCode like this:
$AVSCode="Y:3585460f5bc4f800:NYZS:093250860081744XF3LW 01:";
Then I am trying to evaluate it like this:
$Address=intval(substr($AVSCode,19,1));
$ZipCode=intval(substr($AVSCode,20,1));
$CVM=intval(substr($AVSCode,22,1));
if ($Address != "Y"){
$error.="The Address provided does not match the information on file with your card issuer.<br>\n";
}
if ($ZipCode != "Y"){
$error.="The Zip Code provided does not match the information on file with your card issuer.<br>\n";
}
if ($CVM == "N"){
$error.="The code located on the back of the card provided does not match the information on file with your card issuer.<br>\n";
}
Is this correct?
I then want to pass the information to another page displaying any errors or pass to a different page if no errors like this:
//if any errors occur
if ($error){
header("Location: http://www.whatnott.com/avsFailure.php");
$error;
}else{
header("Location: http://www.whatnott.com/avsPassed.php");
}
The avsFailure.php page should display the errors like this:
<?
if ($error) {//if there is any error message, print it to the screen
echo "<table width=550 align=\"center\" div align=\"center\"><br /><font color=red><b>The following problems occurred:</b><br /></font><font color=#000000 size=1>\n";
print ("$error");
}
?>
Is this correct?
Thanks for your help.