Forum Moderators: coopster

Message Too Old, No Replies

Comparing Strings

         

andrewsmd

9:07 pm on Jul 31, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Maybe it is because it is the end of the day, but I am at a loss of words on this one. I have a function that takes in a file name, a counter and an increment. It opens the file stores it into an array split on a * because the file is inline. The file looks something like this *contents*userID*blahblahblah. Now my function stores that file into and array like this
array[0] = contents
array= userID
array[2] = blahblahblah

The problem is we have different user IDs. Some of them are 7 characters and some are 8. This is how I do a check for them. (assume $arrayExplode[43] is the username)

//if it is the 2b guy then we grab 7 characters otherwise we grab 8 for the user id
if($arrayExplode[43] == "S21762B~PER"){
$userName = substr($arrayExplode[43], 0, 7);
echo("if");
}
elseif((trim($arrayExplode[43]) == "S21762FJG~PER") ¦¦ (trim($arrayExplode[43]) == "S21762FUZ~PER") ¦¦
(trim($arrayExplode[43]) == "S21762FFW~PER") ¦¦ (trim($arrayExplode[43]) == "S21762DQR~PER")){
$userName = substr($arrayExplode[43], 0, 8);
}//else
else{
echo("The username $arrayExplode[43] was not recognized.");
die();
}
ok so when $arrayExplode[43] is S21762B~PER the program works fine. However, if it is any of the user ids in the else if it sees them as not matching. I did a var dump on $arrayExplode[43] and can clearly see that it is S2176FJG~PER no white spaces or returns. Anyone know why I am getting a false on this. Thanks

[1][edited by: andrewsmd at 9:11 pm (utc) on July 31, 2008]

andrewsmd

9:10 pm on Jul 31, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Just so you know, the var_dump output on $arrayExplode[43] is this
string(12) "S2176FJG~PER"