SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Zealot
    Join Date
    Apr 2004
    Location
    RS, Brazil
    Posts
    128
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    replace one line ina a file

    Hi! how to replace the lines in a txt file that contain the word ("db.inc"); to ("db.inc.php"); for eg? Does anybody have the routine? thanks

  2. #2
    Tranceoholic lilleman's Avatar
    Join Date
    Feb 2004
    Location
    Írebro, Sweden
    Posts
    2,716
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi,

    I think you can do something like this:

    PHP Code:
    $filename 'name_of_file.php';
    $content file_get_contents($filename);

    $stream fopen($filename'w');
    fwrite($streamstr_replace('("db.inc");''("db.inc.php");'$content));
    fclose($stream); 
    ERIK RIKLUND :: Yes, I've been gone quite a while.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •