I have a file called tracker.txt that contains 3 lines. The txt file is this: http://tracker.cpcheats.co/rookie/tracker.txt. I am using file_get_contents and explode to return each line of the array, like so:
$read = file_get_contents('tracker.txt');
$filed = explode("\n",$read);
$status = $filed[0];
$server = $filed[1];
$room = $filed[2];
I then have an if statement, where the condition is if the first line of tracker.txt ($status) is 'found', then it will write out the second and third line onto the image. It doesn't work.
if ($status == 'found') {
//write out the server room and language (with shadow)
imagettftext($im, 15, 0, 140, 80, $white, $font, $server);
imagettftext($im, 15, 0, 139, 79, $black, $font, $server);
imagettftext($im, 15, 0, 140, 105, $white, $font, $room);
imagettftext($im, 15, 0, 139, 104, $black, $font, $room);
}
The odd thing is, if I just print out $status, $server and $room without the if statement, it works fine and dispays the correct lines. Why isn't it working with the condition? Because, I'm sure the first line of http://tracker.cpcheats.co/rookie/tracker.txt is 'found'.
\rcharacters at the end of each line before the\nyou're exploding on?$file = fopen("tracker.txt","w"); echo fwrite($file,"found\n (EN) Avalanche\nIce Berg"); fclose($file);file()function, which reads the file and returns all lines in an array already.