Current location: Hot Scripts Forums » General Community » Script Requests » PHP - string replace in a text file


PHP - string replace in a text file

Reply
  #1 (permalink)  
Old 06-20-05, 08:04 AM
andrewvideo andrewvideo is offline
Newbie Coder
 
Join Date: May 2005
Posts: 40
Thanks: 0
Thanked 0 Times in 0 Posts
PHP - string replace in a text file

How do you open a Text File Find a string and then repace it. The End Close the file.

I want look for something like

John/tSheffield/tandrew@anywhere.com/ts1

with

John/tSheffield/tandrew@anywhere.com/ts2

I have some code here dose not do not I want
can any help to change this code

This code only adds at the start of the file.

Code:
$delimiter="\t";
$showit = "1";
$name = "Andrew"  ... etc

$addline = "$name$delimiter$from$delimiter$email$delimiter$url$delimiter$comments$delimiter$added$delimiter$isprivate$delimiter$showit$delimiter$settings[newline]";

$fp = @fopen($settings['logfile'],"rb") or problem("Can't open the log file ($settings[logfile]) for reading! CHMOD this file to 666 (rw-rw-rw)!");
$links = @fread($fp,filesize($settings['logfile']));

fclose($fp);
$addline .= $links;
$fp = fopen($settings['logfile'],"wb") or problem("Couldn't open links file ($settings[logfile]) for writing! Please CHMOD all $settings[logfile] to 666 (rw-rw-rw)!");
fputs($fp,$addline);
fclose($fp);
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
PHP code to edit a text file mdhall Script Requests 12 12-23-10 04:03 AM
Upload file to table so ONLY files tied to primary key are displayed in record? grafixDummy PHP 4 12-20-03 04:28 PM
Declared Functions skipper23 PHP 4 12-17-03 10:06 AM
index page not showing up skipper23 PHP 3 12-15-03 01:10 PM
picking random entries with a filter... Double selection problem dsumpter PHP 7 11-16-03 07:19 PM


All times are GMT -5. The time now is 11:44 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.