I'm trying to figure out how to add a piece of text to the beginning of
every line of a text file.  Somewhere, I'm not understanding how the
filesystem stuff works.  This is what I have right now.  I am certain that
I'm missing some kind of fgets and/or fwrites or something in this and can't
figure out how to get it working...

if ( eregi ( "^ex([0-9]{2})([0-9]{2})([0-9]{2}).log" , $flename ,
$date_piece ) ) {
                
     $year = $date_piece[0] + 2000;
     $date_to_add = $year . "-" . $date_piece[1] . "-" . $date_piece[2];

     echo "<tr><td>$flename will have $date_to_add added to each line<br
/>\n";
        
     $file_path = "$path" . "$file";
        
     echo "<br />" . $file_path . "<br />";
     $fp = fopen ( "$file_path" , "a+" );
        
     while ( !feof ($fp) ) {

          // !!!SOMETHING IS MISSING HERE BUT I CAN'T FIGURE OUT WHAT 
          //maybe $line = fgets ( $fp );


          ereg_replace ( "^" , "$date_to_add " , $line );

          //something's probably missing here too...
          //maybe fwrite ( $line , ereg_replace ( "^" , "$date_to_add " ,
$line ) );
            
     }
        
     fclose ( $fp );
}

---------------------
John Asendorf - [EMAIL PROTECTED]
Web Applications Developer
http://www.lcounty.com - NEW FEATURES ADDED DAILY!
Licking County, Ohio, USA
740-349-3631
Nullum magnum ingenium sine mixtura dementiae fuit

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

Reply via email to