text file
| From: | John Taylor-Johnston | Date: | Wed, 05 Jun 2002 23:00:22 +0000 |
| Subject: | text file | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-100828@lists.php.net to get a copy of this message | ||
I want to open a text file which has 12 lines and
(1) insert a new line at line[0]
(2) re-save the text file only with 12 lines (Therefore line[12] gets
chopped out.
I had some code to do this with Perl.
open (NEW, ">$filepath\\$file");
print NEW "$something";
for ($i = 2; $i < 12; $i++)
{
print NEW "$lines[$i]";
print "$lines[$i]";
}
How can I do it now with PHP?
Open the file (http://www.php.net/manual/en/function.fopen.php)
Suck a text file into an array. <-------??
Insert at line[0] <-------??
and rewrite the file.
(http://www.php.net/manual/en/function.fopen.php)
John