If I display $d[0]
it is [email protected]
but it is refusing to accept the if...
$d = file("mails.txt");
if ($d[0] == "[email protected]") {
echo "JOW!";
}
echo $d[0];
Any idea?
Try calling the trim function on the $d[0]
, which will remove all new line characters at the beginning and end of the string.
$d = file("mails.txt");
if(trim($d[0])=="[email protected]"){
echo "JOW!";
}
echo $d[0];
or not include any new lines at all:
$d = file("mails.txt", FILE_IGNORE_NEW_LINES);
if($d[0]=="[email protected]"){
echo "JOW!";
}
echo $d[0];
Each line in the resulting array will include the line ending, unless FILE_IGNORE_NEW_LINES is used, so you still need to use rtrim() if you do not want the line ending present.
From: http://php.net/manual/en/function.file.php
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With