SOLUTION: Final version of news reader.
| From: | Jesus Climent | Date: | Thu, 30 Nov 2000 16:53:06 +0000 |
| Subject: | SOLUTION: Final version of news reader. | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-28075@lists.php.net to get a copy of this message | ||
How to read news from a file with the format:
<noticia>
Title|other_data_for_your_information
text
text
more_text
<end>
<noticia>
_same-format_
<end>
the open_table() , titulo() , fin() and close_table() are just functions
to control the table structure.
Thanks for you help.
daTa
<?
function read_news() {
$filename = "./noticias.data";
$contents = file ($filename);
open_table();
$lines = count($contents);
for ($j = 0; $j < $lines ; $j++) {
if ($contents[$j] == "<noticia>\n") {
print("$contents[$j]");
$not_done = 1;
for ($line = 1; $not_done; $line++) {
if (($contents[$j + $line] == "<noticia>\n") || ($line > $lines)) {
$not_done = 0;
} else {
$good_line = $contents[$j + $line];
$datos = explode("|", $good_line);
titulo($datos[0]);
$body = 1;
for ($line = $line+1 ; $body; $line++) {
if (ereg("<end>", $contents[$j + $line])) {
$body=0;
} else {
$body_text = $contents[$j + $line];
print("$body_text");
}
}
fin();
$not_done = 0;
}
}
}
}
close_table();
}
?>