word replacement in file

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • hemashiki
    New Member
    • Aug 2006
    • 34

    word replacement in file

    hi
    i need a help....
    while opening a file.i want to find a word in that file, then replace the word with another word.
    it is like find and replace in MS-WORD
    can anyone suggest me
  • ronverdonk
    Recognized Expert Specialist
    • Jul 2006
    • 4259

    #2
    Use the str_replace() command in PHP.
    [php]str_replace("wo rd to be replaced", "replacemen t", $string);[/php]
    See for more infot the PHP documentation at str_replace command

    Ronald :cool:

    Comment

    • lordspace
      New Member
      • Nov 2006
      • 10

      #3
      ....
      $buffer = preg_replace('# \bWORD\b#si', 'NEWWORD', $buffer);
      ....

      Comment

      Working...