Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5

Thread: Editing file

  1. #1
    New Coder
    Join Date
    Sep 2005
    Posts
    56
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Editing file

    I've got this script here, it edits the contents of a file. Does anyone know how to make it edit x to y of a file?

    PHP Code:
    <?
    // Submission Part
    if ($submit) {
    $fp fopen('YOURPAGE.php''w');
    fwrite($fpstripslashes($newdata));
    fclose($fp);
    }

    $fp fopen('YOURPAGE.php''r');
    while (!
    feof($fp)) {
    $data .= fgets($fp4096);
    }
    fclose($fp);
    echo 
    "
    <html>
    <head>
    <title>PAGE</title>
    </head>

    <body>
    <form action='edit.php' method='post'>
    <textarea name='newdata' rows='20' cols='50'>
    $data
    </textarea>
    <br>
    <input type='submit' name='submit' value='Submit'>
    </form>
    </body>
    </html>"
    ;
    ?>

  • #2
    Senior Coder
    Join Date
    Apr 2005
    Location
    Colorado, United States
    Posts
    1,208
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Well, if you want to replace X with Y, then use str_replace() on the data.
    "$question = ( to() ) ? be() : ~be();"

  • #3
    New Coder
    Join Date
    Sep 2005
    Posts
    56
    Thanks
    0
    Thanked 0 Times in 0 Posts
    LMAO, I meant that I want to edit a certiant chunk from the file from like x to y in the file.

  • #4
    Senior Coder
    Join Date
    Sep 2005
    Posts
    1,791
    Thanks
    5
    Thanked 36 Times in 35 Posts
    Where x and y are what?
    Line numbers? Words?

  • #5
    New Coder
    Join Date
    Sep 2005
    Posts
    56
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I've got this file yourpage.php but when I edit it with the script a showed you, It edits the whole source. I just want it to edit a certian chunk of the source.
    Last edited by jabbic; 01-12-2006 at 07:39 PM.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •