Re: Find - n - replace

From: Date: Wed, 23 May 2001 06:08:43 +0000
Subject: Re: Find - n - replace
References: 1  Groups: php.db 
Request: Send a blank email to php-db+get-9555@lists.php.net to get a copy of this message
try looking at the fseek function, i think that does what you want: http://uk.php.net/manual/en/function.fseek.php "John Starkey" <jstarkey@advancecreations.com> wrote in message news:Pine.LNX.4.30.0105222136570.12616-100000@peak.advancecreations.com... > Hello all. > > I'm trying to set up a quick find and replace script. It's finding, and > it's pasting what I want, but on the following line, I can't get it to > replace. Can anyone help? > > #!/usr/local/bin/php -q > > <?php > > $fp = fopen( "./somefile.html","r+"); > while ( !feof( $fp ) ) { > $line = fgets( $fp, 4096 ); > if ( eregi( "<td", $line ) ) { > if ( eregi( "4[0-9]{2}", $line ) ) { > $liner = eregi_replace( "4[0-9]{2}", "470", $line ); > fputs( $fp, $liner, strlen( $liner ) ); > } > } > } > > fclose( $fp ); > > ?> > > Can anyone tell me how I can back the fput up one line so it overwrites > the result of the search? > > Thanks, > > John > > > -- > PHP Database Mailing List (http://www.php.net/) > To unsubscribe, e-mail: php-db-unsubscribe@lists.php.net > For additional commands, e-mail: php-db-help@lists.php.net > To contact the list administrators, e-mail: php-list-admin@lists.php.net >

« previous php.db (#9555) next »