Re: Simple Text Files Functions...

From: Date: Tue, 20 May 2003 23:18:37 +0000
Subject: Re: Simple Text Files Functions...
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-148337@lists.php.net to get a copy of this message
> $string = preg_replace('/(</stories>)$/', $subsrting, $text); You're calling the variable 'subsrting' here ... that would hurt the script. And it's probably bad form to create variables that are also the names of functions. -- Matt Grimm Web Developer The Health TV Channel, Inc. (a non - profit organization) 3820 Lake Otis Parkway Anchorage, AK 99508 907.770.6200 ext. 686 907.336.6205 (fax) E-mail: mgrimm@healthtvchannel.org Web: www.healthtvchannel.org ----- Original Message ----- From: "Russell P Jones" <rjones@email.unc.edu> To: <php-general@lists.php.net> Sent: Tuesday, May 20, 2003 3:12 PM Subject: [PHP] Simple Text Files Functions... > Ok so Im a newbie, but I really need some help with this... > > All I am trying to do is open a file of just text, replace 5 characters > that appear once in the document with a string of text that has the > variable named $string. > > Here was my best try... > > <? > $substring = 'my new substring'; > > $fp = fopen($filename, "r") or die("sorry folks"); > > while (!feof($fp)){ $text = fread($fp, filesize($fp)); } > > fclose($fp); > > $fp2 = fopen($filename, "w") or die("sorry folks again"); > $string = preg_replace('/(</stories>)$/', $subsrting, $text); > $bytes = fwrite($fp2, $string); > fclose($fp2); > echo $bytes; > > ?> > > Couple of questions... > (1) Why is this not working :) > (2) Do i need to do something special since the characters I am searching > for includes a <, /, and > ? > (3) Why am I hopeless? > > Russ > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > >

« previous php.general (#148337) next »