> Also does anyone know how to insert a text on about the 4 or 5 line of a
file using php? I can add text to the end of a file and to the beginning,
but I'm not sure how to do it for specific lines.

Ok, I whipped of a quick set of code that I have not tested

$lineCounter = 0;

if($theFile = fopen("yourfile.txt", "r+"){
      $theLine = fgets($theFile);
      if($lineCounter == 4){
         fputs($theFile, "the stuff you wish to add");

We used to do this thing with PERL many years ago for a very basic web
article publishing script where we opened a template file and searched for
comment lines and inserted the appropriate article information, which could
be done as above. As I recall it took some fairly complex regex and many
more lines of code, though I am sure it could be rewritten now.

HTH! Peace ...


Growing old is mandatory, growing up is optional

* Texas PHP Developers Conf  Spring 2003            *
* T Bar M Resort & Conference Center                *
* New Braunfels, Texas                              *
* Contact [EMAIL PROTECTED]       *
*                                                   *
* Want to present a paper or workshop? Contact now! *

PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to