I have a php script that writes data to a text file line by line. On a webpage, I use
$array = file('db/data.txt');
to read each line of the text file into an array. I then echo the array elements into my page using for example
<a href="<?php echo $array[5];?>" target="_blank">
This all works fine. However, what I need to be able to do is determine if the variable is empty (meaning there is nothing in the text value on that particular line in the text file) and if it is, have the code do something.
I have tried
<? if ($array[27] != "") { ?>
do something here
<? } ?>
and also tried
<? if ($array[27]) { ?>
do something
<? } ?>
but regardless, the code still runs when I know the array element holds no value in it.
When putting the data from the text file into the array, does it make an empty line fill the element with something wierd ? What should I be using in my if statement to determine if the array element is empty?
Please help. I greatly appreciate it.