Okay, this might be stupid questions, but here goes:
Where is $is_blocked NOT 1?
Where and how are you checking it?
What does your function DO, exactly?
Why do you build up the $out string if you're not going to use it?
Why do you set the value of $is_blocked to the string "1" instead of the integer 1, or better yet, the boolean true?
See, your function answers a question: Is this email blocked? That answer is yes or no; boolean values.
Another problem -- you search through the ENTIRE file contents before returning a value. If your blocked email is the first in the list, you'll still waste the time making string comparisons for every other address in the array... why?
Here's a much more efficient rewriting of your function:
function is_blocked($email)
{
$blocked_file = "members/block_list_file.txt";
$list = file_get_contents($blocked_file);
$list = stripslashes($list);
$lines = explode("|",$list);
return in_array($email, $lines);
}
http://www.php.net/file_get_contents
http://www.php.net/in_array
See, you pass in an email address. The function tells you if that email address is in the file. Here's another rewriting:
function is_blocked($email)
{
$blocked_file = "members/block_list_file.txt";
$list = file_get_contents($blocked_file);
$list = stripslashes($list);
return (false !== stripos("|{$email}|", $list));
}
http://www.php.net/stripos
This rewriting is nicer because you don't spend a bunch of time or waste memory splitting the file contents up into an array.
Take care,
Nik
http://www.bigaction.org/