try looking at the fseek function, i think that does what you want:
http://uk.php.net/manual/en/function.fseek.php


"John Starkey" <[EMAIL PROTECTED]> wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> 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: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> To contact the list administrators, e-mail: [EMAIL PROTECTED]
>



-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to