Forum Moderators: coopster
I think my problem is the syntax, since I'm new to PHP.
To check for a blankline, I'm using the code :
<i>if ($content == "")</i>
Is that correct?
The text file is a fixture list that looks like this
---------------------------
Thursday March 17
8:15pm: RCFC v United
Sunday March 20
10am: Titans v Amigos
12pm: United v Cobras
2pm: Rcfc v Boca Jr
Thursday March 24
8:15pm: Boca Jr v Titans
etc
etc
------------------
I'm using fgets() to read line by line, and when I find a blank line, I want to make the next line bold (ie the date).
At the moment, it only makes the first date bold. I suspect that the code is not detecting any other blank lines in order to make other bolds.
The code is below.
<?php
$filename = "content/matches.txt";
$fp = fopen ($filename, "r");
$PrevLineBlank=true; // default since first line is always a date
$output = "<br/>";
while (!feof ($fp)) {
$content = fgets( $fp, filesize($filename) );
if ($PrevLineBlank==true) { // it must be the date
$output .= "<p><strong>$content</strong><br/>";
$PrevLineBlank=!$PrevLineBlank;
}
else
if ($content == "") { // must be a blank line
$output .= "</p>";
$PrevLineBlank=!$PrevLineBlank;
}
else { // must be a fixture or result
$output .= "$content<br/>";
}
}
fclose ($fp);
echo $output;
?>
[edited by: coopster at 4:37 pm (utc) on Mar. 9, 2005]
[edit reason] removed urls per TOS [webmasterworld.com] [/edit]
It has come up before [webmasterworld.com], and it is no doubt one of the most difficult obstacles for any cross-platform programmer.