October 15th, 2000, 01:54 PM
How can I cath the first line of a .txt file or whatever in PHP, using include("") ?
I need it for this, like, I'm thinking of doing a site with reviews on it, and I want to have one .php file for all the reviews. So that I can open a review using review.php?review_id=photoshop6
Im planning to have each review as one txt file, that I write "by hand" with the first line as the title. (If anyone knows of a better, smarter and faster way to do this, let me know, i'm new with PHP. With MySQL or whatever.)
The script should first parse the first line of the .txt file and use that one for title, so i can use a different size of text for it, and then it should parse the rest of the file and use for body text.
Please help me with this.
October 16th, 2000, 12:30 AM
I'm not sure what you mean, but maybe this is what you want :
October 16th, 2000, 04:26 AM
I'd stick to PHP and MySQL instead, as I think it is easier to maintain and faster than using filereading. Create MySQL-table(s) that stores all your info and let PHP read from them. The table-layout depends on what you want to do (how many tables, what content etc), but as a small example:
| id | program | review |
| 1 | photoshop | blahblah |
| 2 | gimp | whatever |
| 3 | bruce | and so on|
In your PHP-file you read from this table and can then format your title different from the contents of the review. You can also show only the first 100 characters from the review-field on page one, and then use the id as a link to next page where you show the whole reviewtext.
That's how I would approach it, but the choice is yours...
October 16th, 2000, 06:16 AM
$filename = "yourfilename.txt";
$hits = file($filename); // The file is in an array
$totaal = count($hits); //the nr of lines in $hits!
for($i=0 ; $i < $totaal+1 ; $i++)
$line = $hits[$i]; //
This must show every line in the txt file
Quote the Dokus:"NeverMore!"