This is driving me nuts. I have a test.html file that contains either "OPEN" or "CLOSED" inside of it. I do a file_get_contents()
:
$testA = file_get_contents ('files/test.html');
if ($testA == 'OPEN') {
$color1 = '#00800';
$back1 = '#DDFFDD';
}
else {
$color1 = '#FF0000';
$back1 = '#FFD9CC';
}
It returns false even if the value in my test.html = OPEN.
Using $testA = "OPEN";
works just fine. I'm a newbie, so I know its something simple that I'm overlooking. Any help will be appreciated
Try this:
$testA = file_get_contents ('files/test.html');
if(strpos($testA, 'OPEN') !== FALSE){
$color1 = '#00800';
$back1 = '#DDFFDD';
}else{
$color1 = '#FF0000';
$back1 = '#FFD9CC';
}
Edit You can read more about strpos() here.