deleting a line

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • programming

    #1

    deleting a line

    how do i delete from a text file 1 of the following lines:


    jon|scott
    adam|smith <--delete
    paul|clark

    say i would like to delete the middle line of this txt, in member.txt
    what php code or logic would help me accomplish this?

    Also i am clicking on a hyperlink that is keeping count of the entries
    i have
    made. e.g php?record_id =1
    php?record_id =2

  • Toby A Inkster

    #2
    Re: deleting a line

    programming wrote:
    say i would like to delete the middle line of this txt, in member.txt
    what php code or logic would help me accomplish this?
    For a small file:

    1. Read member.txt into an array (the "file" function is
    your friend);
    2. Make the changes to the array (the "unset" function is
    your friend);
    3. Output the array to "member-new.txt";
    4. Delete "member.txt ";
    5. Rename "member-new.txt" to "member.txt ";

    If the file is larger (more than say, 500 kB) this might become a bit
    memory-hungry, and it's worth looking at iterating over each line of the
    file individually rather than reading it all into memory at once.

    --
    Toby A Inkster BSc (Hons) ARCS
    Contact Me ~ http://tobyinkster.co.uk/contact
    Geek of ~ HTML/SQL/Perl/PHP/Python*/Apache/Linux

    * = I'm getting there!

    Comment

    • SUtrap

      #3
      Re: deleting a line

      Hi,

      you need to open two streams, one for reading, one for writing.

      Be wary by more than one request at a time!!! ( errors!)

      there is no delete function couse a file is only a stream ;)

      Comment

      • Jerry Stuckle

        #4
        Re: deleting a line

        programming wrote:
        how do i delete from a text file 1 of the following lines:
        >
        >
        jon|scott
        adam|smith <--delete
        paul|clark
        >
        say i would like to delete the middle line of this txt, in member.txt
        what php code or logic would help me accomplish this?
        >
        Also i am clicking on a hyperlink that is keeping count of the entries
        i have
        made. e.g php?record_id =1
        php?record_id =2
        >
        Or, better yet, learn to use a SQL database.

        --
        =============== ===
        Remove the "x" from my email address
        Jerry Stuckle
        JDS Computer Training Corp.
        jstucklex@attgl obal.net
        =============== ===

        Comment

        • programming

          #5
          Re: deleting a line

          On Apr 11, 10:57 pm, Jerry Stuckle <jstuck...@attg lobal.netwrote:
          programming wrote:
          how do i delete from a text file 1 of the following lines:
          >
          jon|scott
          adam|smith <--delete
          paul|clark
          >
          say i would like to delete the middle line of this txt, in member.txt
          what php code or logic would help me accomplish this?
          >
          Also i am clicking on a hyperlink that is keeping count of the entries
          i have
          made. e.g php?record_id =1
          php?record_id =2
          >
          Or, better yet, learn to use a SQL database.
          >
          --
          =============== ===
          Remove the "x" from my email address
          Jerry Stuckle
          JDS Computer Training Corp.
          jstuck...@attgl obal.net
          =============== ===
          yes, but this assignment i am doing does not require that...the next
          one will be using SQL

          Comment

          • programming

            #6
            Re: deleting a line

            On Apr 11, 7:08 pm, Toby A Inkster <usenet200...@t obyinkster.co.u k>
            wrote:
            programming wrote:
            say i would like to delete the middle line of this txt, in member.txt
            what php code or logic would help me accomplish this?
            >
            For a small file:
            >
            1. Read member.txt into an array (the "file" function is
            your friend);
            2. Make the changes to the array (the "unset" function is
            your friend);
            3. Output the array to "member-new.txt";
            4. Delete "member.txt ";
            5. Rename "member-new.txt" to "member.txt ";
            >
            If the file is larger (more than say, 500 kB) this might become a bit
            memory-hungry, and it's worth looking at iterating over each line of the
            file individually rather than reading it all into memory at once.
            >
            --
            Toby A Inkster BSc (Hons) ARCS
            Contact Me ~http://tobyinkster.co.uk/contact
            Geek of ~ HTML/SQL/Perl/PHP/Python*/Apache/Linux
            >
            * = I'm getting there!
            Thanks for you steps, i had a go at doing it..is this what you meant
            by any chance?

            <?php

            $line = file ("./member.txt", "w");
            unset($line);

            $line = fopen("./member-new.txt");

            unlink("./member.txt")

            rename("member-new.txt","membe r.txt");

            fclose($line);


            ?>

            I am getting a parse error, and i am not sure if i am doing this
            right??

            Parse error: syntax error, unexpected T_STRING in /volumes/data1/home/
            pioannou/public_html/php/Assignment11/admin/delete_member.p hp on line
            11

            Comment

            • Jerry Stuckle

              #7
              Re: deleting a line

              programming wrote:
              On Apr 11, 10:57 pm, Jerry Stuckle <jstuck...@attg lobal.netwrote:
              >programming wrote:
              >>how do i delete from a text file 1 of the following lines:
              >>jon|scott
              >>adam|smith <--delete
              >>paul|clark
              >>say i would like to delete the middle line of this txt, in member.txt
              >>what php code or logic would help me accomplish this?
              >>Also i am clicking on a hyperlink that is keeping count of the entries
              >>i have
              >>made. e.g php?record_id =1
              >> php?record_id =2
              >Or, better yet, learn to use a SQL database.
              >>
              >--
              >============== ====
              >Remove the "x" from my email address
              >Jerry Stuckle
              >JDS Computer Training Corp.
              >jstuck...@attg lobal.net
              >============== ====
              >
              yes, but this assignment i am doing does not require that...the next
              one will be using SQL
              >
              Ah, getting help with your homework...

              --
              =============== ===
              Remove the "x" from my email address
              Jerry Stuckle
              JDS Computer Training Corp.
              jstucklex@attgl obal.net
              =============== ===

              Comment

              • programming

                #8
                Re: deleting a line

                On Apr 11, 11:20 pm, Jerry Stuckle <jstuck...@attg lobal.netwrote:
                programming wrote:
                On Apr 11, 10:57 pm, Jerry Stuckle <jstuck...@attg lobal.netwrote:
                programming wrote:
                >how do i delete from a text file 1 of the following lines:
                >jon|scott
                >adam|smith <--delete
                >paul|clark
                >say i would like to delete the middle line of this txt, in member.txt
                >what php code or logic would help me accomplish this?
                >Also i am clicking on a hyperlink that is keeping count of the entries
                >i have
                >made. e.g php?record_id =1
                > php?record_id =2
                Or, better yet, learn to use a SQL database.
                >
                --
                =============== ===
                Remove the "x" from my email address
                Jerry Stuckle
                JDS Computer Training Corp.
                jstuck...@attgl obal.net
                =============== ===
                >
                yes, but this assignment i am doing does not require that...the next
                one will be using SQL
                >
                Ah, getting help with your homework...
                >
                --
                =============== ===
                Remove the "x" from my email address
                Jerry Stuckle
                JDS Computer Training Corp.
                jstuck...@attgl obal.net
                =============== ===
                Yeah i am pleased with my progress with it so far, hopefully forums
                can be a help as i progress

                Comment

                • =?iso-8859-1?Q?Kim_Andr=E9_Aker=F8?=

                  #9
                  Re: deleting a line

                  programming wrote:
                  On Apr 11, 7:08 pm, Toby A Inkster <usenet200...@t obyinkster.co.u k>
                  wrote:
                  programming wrote:
                  say i would like to delete the middle line of this txt, in
                  member.txt what php code or logic would help me accomplish this?
                  For a small file:

                  1. Read member.txt into an array (the "file" function is
                  your friend);
                  2. Make the changes to the array (the "unset" function is
                  your friend);
                  3. Output the array to "member-new.txt";
                  4. Delete "member.txt ";
                  5. Rename "member-new.txt" to "member.txt ";

                  If the file is larger (more than say, 500 kB) this might become a
                  bit memory-hungry, and it's worth looking at iterating over each
                  line of the file individually rather than reading it all into
                  memory at once.
                  >
                  Thanks for you steps, i had a go at doing it..is this what you meant
                  by any chance?
                  >
                  <?php
                  >
                  $line = file ("./member.txt", "w");
                  unset($line);
                  >
                  $line = fopen("./member-new.txt");
                  >
                  unlink("./member.txt")
                  >
                  rename("member-new.txt","membe r.txt");
                  >
                  fclose($line);
                  >
                  >
                  ?>
                  >
                  I am getting a parse error, and i am not sure if i am doing this
                  right??
                  >
                  Parse error: syntax error, unexpected T_STRING in /volumes/data1/home/
                  pioannou/public_html/php/Assignment11/admin/delete_member.p hp on line
                  11
                  The parse error itself comes from the missing semicolon on the line
                  with the unlink() function.

                  Second, you have placed the "w" parameter on the wrong function (on the
                  file() function instead of the fopen() function).

                  Thirdly, you're attempting to move/rename the new file BEFORE closing
                  the file handle for it. This could cause problems in terms of
                  locking/permissions.

                  Fourthly, you still haven't output the updated array to the new file
                  yet. Also, you're unsetting (deleting) the entire array instead of just
                  a single item.

                  After fixing the errors, the final source code snippet should look
                  something like this (with comments attached):

                  <?php

                  // Which line number (counting from 0) should we delete?
                  $line_to_delete = 4;

                  // Load the lines into an array; newlines are still attached
                  $lines = file ("./member.txt");

                  // Delete the line number from the array
                  unset($lines[$line_to_delete]);

                  // Open the new file for writing
                  $lines_update = fopen("./member-new.txt", "w");

                  // 1. Join the array to a single string (newlines are already attached)
                  // 2. Write the updated array to the new file
                  fwrite($lines_u pdate, join("", $lines);

                  // Close the file handle to allow other operations on the file
                  fclose($lines_u pdate);

                  // Remove the old file
                  unlink("./member.txt");

                  // Rename the new file to use the old filename, replacing the old file
                  rename("member-new.txt","membe r.txt");

                  ?>

                  --
                  Kim André Akerø
                  - kimandre@NOSPAM betadome.com
                  (remove NOSPAM to contact me directly)

                  Comment

                  • Toby A Inkster

                    #10
                    Re: deleting a line

                    Kim André Akerø wrote:
                    // 1. Join the array to a single string (newlines are already attached)
                    // 2. Write the updated array to the new file
                    fwrite($lines_u pdate, join("", $lines);
                    Missing a closing parenthesis here, but otherwise, yes, something like
                    this. Though personally I'd check the return value from fwrite() before
                    you go and do this:
                    // Remove the old file
                    unlink("./member.txt");
                    >
                    // Rename the new file to use the old filename, replacing the old file
                    rename("member-new.txt","membe r.txt");
                    --
                    Toby A Inkster BSc (Hons) ARCS
                    Contact Me ~ http://tobyinkster.co.uk/contact
                    Geek of ~ HTML/SQL/Perl/PHP/Python*/Apache/Linux

                    * = I'm getting there!

                    Comment

                    • programming

                      #11
                      Re: deleting a line

                      On Apr 11, 10:56 pm, Kim André Akerø <kiman...@NOSPA Mbetadome.com>
                      wrote:
                      programming wrote:
                      On Apr 11, 7:08 pm, Toby A Inkster <usenet200...@t obyinkster.co.u k>
                      wrote:
                      programming wrote:
                      say i would like to delete the middle line of this txt, in
                      member.txt what php code or logic would help me accomplish this?
                      >
                      For a small file:
                      >
                      1. Read member.txt into an array (the "file" function is
                      your friend);
                      2. Make the changes to the array (the "unset" function is
                      your friend);
                      3. Output the array to "member-new.txt";
                      4. Delete "member.txt ";
                      5. Rename "member-new.txt" to "member.txt ";
                      >
                      If the file is larger (more than say, 500 kB) this might become a
                      bit memory-hungry, and it's worth looking at iterating over each
                      line of the file individually rather than reading it all into
                      memory at once.
                      >
                      Thanks for you steps, i had a go at doing it..is this what you meant
                      by any chance?
                      >
                      <?php
                      >
                      $line = file ("./member.txt", "w");
                      unset($line);
                      >
                      $line = fopen("./member-new.txt");
                      >
                      unlink("./member.txt")
                      >
                      rename("member-new.txt","membe r.txt");
                      >
                      fclose($line);
                      >
                      ?>
                      >
                      I am getting a parse error, and i am not sure if i am doing this
                      right??
                      >
                      Parse error: syntax error, unexpected T_STRING in /volumes/data1/home/
                      pioannou/public_html/php/Assignment11/admin/delete_member.p hp on line
                      11
                      >
                      The parse error itself comes from the missing semicolon on the line
                      with the unlink() function.
                      >
                      Second, you have placed the "w" parameter on the wrong function (on the
                      file() function instead of the fopen() function).
                      >
                      Thirdly, you're attempting to move/rename the new file BEFORE closing
                      the file handle for it. This could cause problems in terms of
                      locking/permissions.
                      >
                      Fourthly, you still haven't output the updated array to the new file
                      yet. Also, you're unsetting (deleting) the entire array instead of just
                      a single item.
                      >
                      After fixing the errors, the final source code snippet should look
                      something like this (with comments attached):
                      >
                      <?php
                      >
                      // Which line number (counting from 0) should we delete?
                      $line_to_delete = 4;
                      >
                      // Load the lines into an array; newlines are still attached
                      $lines = file ("./member.txt");
                      >
                      // Delete the line number from the array
                      unset($lines[$line_to_delete]);
                      >
                      // Open the new file for writing
                      $lines_update = fopen("./member-new.txt", "w");
                      >
                      // 1. Join the array to a single string (newlines are already attached)
                      // 2. Write the updated array to the new file
                      fwrite($lines_u pdate, join("", $lines);
                      >
                      // Close the file handle to allow other operations on the file
                      fclose($lines_u pdate);
                      >
                      // Remove the old file
                      unlink("./member.txt");
                      >
                      // Rename the new file to use the old filename, replacing the old file
                      rename("member-new.txt","membe r.txt");
                      >
                      ?>
                      >
                      --
                      Kim André Akerø
                      - kiman...@NOSPAM betadome.com
                      (remove NOSPAM to contact me directly)
                      this sounds good, but the only think i am confused about know is the
                      line_to_delete = 4;
                      is there any chance of matching the entry line from my web page to the
                      line
                      in the text file by using a superglobal to catch the value that needs
                      to be matched to the line in the file...

                      Comment

                      • amygdala

                        #12
                        Re: deleting a line


                        "programmin g" <periklis.ioann ou@gmail.comsch reef in bericht
                        news:1176327375 .195579.189940@ d57g2000hsg.goo glegroups.com.. .
                        On Apr 11, 10:56 pm, Kim André Akerø <kiman...@NOSPA Mbetadome.com>
                        wrote:
                        programming wrote:
                        On Apr 11, 7:08 pm, Toby A Inkster <usenet200...@t obyinkster.co.u k>
                        wrote:
                        programming wrote:
                        say i would like to delete the middle line of this txt, in
                        member.txt what php code or logic would help me accomplish this?
                        >
                        For a small file:
                        >
                        1. Read member.txt into an array (the "file" function is
                        your friend);
                        2. Make the changes to the array (the "unset" function is
                        your friend);
                        3. Output the array to "member-new.txt";
                        4. Delete "member.txt ";
                        5. Rename "member-new.txt" to "member.txt ";
                        >
                        If the file is larger (more than say, 500 kB) this might become a
                        bit memory-hungry, and it's worth looking at iterating over each
                        line of the file individually rather than reading it all into
                        memory at once.
                        >
                        Thanks for you steps, i had a go at doing it..is this what you meant
                        by any chance?
                        >
                        <?php
                        >
                        $line = file ("./member.txt", "w");
                        unset($line);
                        >
                        $line = fopen("./member-new.txt");
                        >
                        unlink("./member.txt")
                        >
                        rename("member-new.txt","membe r.txt");
                        >
                        fclose($line);
                        >
                        ?>
                        >
                        I am getting a parse error, and i am not sure if i am doing this
                        right??
                        >
                        Parse error: syntax error, unexpected T_STRING in /volumes/data1/home/
                        pioannou/public_html/php/Assignment11/admin/delete_member.p hp on line
                        11
                        >
                        The parse error itself comes from the missing semicolon on the line
                        with the unlink() function.
                        >
                        Second, you have placed the "w" parameter on the wrong function (on the
                        file() function instead of the fopen() function).
                        >
                        Thirdly, you're attempting to move/rename the new file BEFORE closing
                        the file handle for it. This could cause problems in terms of
                        locking/permissions.
                        >
                        Fourthly, you still haven't output the updated array to the new file
                        yet. Also, you're unsetting (deleting) the entire array instead of just
                        a single item.
                        >
                        After fixing the errors, the final source code snippet should look
                        something like this (with comments attached):
                        >
                        <?php
                        >
                        // Which line number (counting from 0) should we delete?
                        $line_to_delete = 4;
                        >
                        // Load the lines into an array; newlines are still attached
                        $lines = file ("./member.txt");
                        >
                        // Delete the line number from the array
                        unset($lines[$line_to_delete]);
                        >
                        // Open the new file for writing
                        $lines_update = fopen("./member-new.txt", "w");
                        >
                        // 1. Join the array to a single string (newlines are already attached)
                        // 2. Write the updated array to the new file
                        fwrite($lines_u pdate, join("", $lines);
                        >
                        // Close the file handle to allow other operations on the file
                        fclose($lines_u pdate);
                        >
                        // Remove the old file
                        unlink("./member.txt");
                        >
                        // Rename the new file to use the old filename, replacing the old file
                        rename("member-new.txt","membe r.txt");
                        >
                        ?>
                        >
                        --
                        Kim André Akerø
                        - kiman...@NOSPAM betadome.com
                        (remove NOSPAM to contact me directly)
                        this sounds good, but the only think i am confused about know is the
                        line_to_delete = 4;
                        is there any chance of matching the entry line from my web page to the
                        line
                        in the text file by using a superglobal to catch the value that needs
                        to be matched to the line in the file...
                        $line_to_delete = 'this is my test line.';

                        /*
                        // instead of:
                        unset($lines[$line_to_delete]);
                        // use:
                        */

                        // deletes every occurence of the line, case insensitive
                        foreach($lines as $key =$value)
                        {
                        if(strtolower($ value) == strtolower($lin e_to_delete))
                        {
                        unset($lines[$key]);
                        }
                        }

                        // or, deletes first occurence of the line, case insensitive
                        $found = false;
                        while (!$found && list($key, $value) = each ($lines)) {
                        if(strtolower($ value) == strtolower($lin e_to_delete))
                        {
                        unset($lines[$key]);
                        $found = true;
                        }
                        }


                        Comment

                        • programming

                          #13
                          Re: deleting a line

                          On Apr 12, 8:44 am, "amygdala" <nore...@norepl y.comwrote:
                          "programmin g" <periklis.ioan. ..@gmail.comsch reef in berichtnews:117 6327375.195579. 189940@d57g2000 hsg.googlegroup s.com...
                          On Apr 11, 10:56 pm, Kim André Akerø <kiman...@NOSPA Mbetadome.com>
                          wrote:
                          >
                          >
                          >
                          programming wrote:
                          On Apr 11, 7:08 pm, Toby A Inkster <usenet200...@t obyinkster.co.u k>
                          wrote:
                          programming wrote:
                          say i would like to delete the middle line of this txt, in
                          member.txt what php code or logic would help me accomplish this?
                          >
                          For a small file:
                          >
                          1. Read member.txt into an array (the "file" function is
                          your friend);
                          2. Make the changes to the array (the "unset" function is
                          your friend);
                          3. Output the array to "member-new.txt";
                          4. Delete "member.txt ";
                          5. Rename "member-new.txt" to "member.txt ";
                          >
                          If the file is larger (more than say, 500 kB) this might become a
                          bit memory-hungry, and it's worth looking at iterating over each
                          line of the file individually rather than reading it all into
                          memory at once.
                          >
                          Thanks for you steps, i had a go at doing it..is this what you meant
                          by any chance?
                          >
                          <?php
                          >
                          $line = file ("./member.txt", "w");
                          unset($line);
                          >
                          $line = fopen("./member-new.txt");
                          >
                          unlink("./member.txt")
                          >
                          rename("member-new.txt","membe r.txt");
                          >
                          fclose($line);
                          >
                          ?>
                          >
                          I am getting a parse error, and i am not sure if i am doing this
                          right??
                          >
                          Parse error: syntax error, unexpected T_STRING in /volumes/data1/home/
                          pioannou/public_html/php/Assignment11/admin/delete_member.p hp on line
                          11
                          >
                          The parse error itself comes from the missing semicolon on the line
                          with the unlink() function.
                          >
                          Second, you have placed the "w" parameter on the wrong function (on the
                          file() function instead of the fopen() function).
                          >
                          Thirdly, you're attempting to move/rename the new file BEFORE closing
                          the file handle for it. This could cause problems in terms of
                          locking/permissions.
                          >
                          Fourthly, you still haven't output the updated array to the new file
                          yet. Also, you're unsetting (deleting) the entire array instead of just
                          a single item.
                          >
                          After fixing the errors, the final source code snippet should look
                          something like this (with comments attached):
                          >
                          <?php
                          >
                          // Which line number (counting from 0) should we delete?
                          $line_to_delete = 4;
                          >
                          // Load the lines into an array; newlines are still attached
                          $lines = file ("./member.txt");
                          >
                          // Delete the line number from the array
                          unset($lines[$line_to_delete]);
                          >
                          // Open the new file for writing
                          $lines_update = fopen("./member-new.txt", "w");
                          >
                          // 1. Join the array to a single string (newlines are already attached)
                          // 2. Write the updated array to the new file
                          fwrite($lines_u pdate, join("", $lines);
                          >
                          // Close the file handle to allow other operations on the file
                          fclose($lines_u pdate);
                          >
                          // Remove the old file
                          unlink("./member.txt");
                          >
                          // Rename the new file to use the old filename, replacing the old file
                          rename("member-new.txt","membe r.txt");
                          >
                          ?>
                          >
                          --
                          Kim André Akerø
                          - kiman...@NOSPAM betadome.com
                          (remove NOSPAM to contact me directly)
                          this sounds good, but the only think i am confused about know is the
                          line_to_delete = 4;
                          is there any chance of matching the entry line from my web page to the
                          line
                          in the text file by using a superglobal to catch the value that needs
                          to be matched to the line in the file...
                          >
                          $line_to_delete = 'this is my test line.';
                          >
                          /*
                          // instead of:
                          unset($lines[$line_to_delete]);
                          // use:
                          */
                          >
                          // deletes every occurence of the line, case insensitive
                          foreach($lines as $key =$value)
                          {
                          if(strtolower($ value) == strtolower($lin e_to_delete))
                          {
                          unset($lines[$key]);
                          }
                          >
                          }
                          >
                          // or, deletes first occurence of the line, case insensitive
                          $found = false;
                          while (!$found && list($key, $value) = each ($lines)) {
                          if(strtolower($ value) == strtolower($lin e_to_delete))
                          {
                          unset($lines[$key]);
                          $found = true;
                          }
                          >
                          }
                          Thanks for the help. However, I am still having a little bit of
                          trouble with deleting a line from a txt
                          file. When i click on the hyper link that is matched to record?=
                          $count,
                          it still wont delete and append the details to the file...

                          here is the code that i am trying to implement. Are there any changes
                          i can make to this code to help me accomplish the task?

                          <?php
                          if(isset($_GET['record_id'])){
                          // Load the lines into an array; newlines are still attached
                          $line_to_delete = $_GET['record_id'];

                          $line=file("mem ber.txt");

                          $found = false;
                          while(!$found && list($key, $value) = each($line)) {
                          if(strtolower($ value) == strtolower($lin e_to_delete))
                          {
                          unset($line[$key]);
                          $found = true;
                          }
                          }
                          }
                          //Open the new file for writing
                          $lines_update = fopen("./member.txt", "w");
                          // 1. Join the array to a single string (newlines are already
                          attached)
                          // 2. Write the updated array to the new file
                          fwrite($lines_u pdate, join("", $line));
                          // Close the file handle to allow other operations on the file
                          fclose($lines_u pdate);
                          // Remove the old file
                          ?>

                          Cheers,
                          Peri

                          Comment

                          • Toby A Inkster

                            #14
                            Re: deleting a line

                            programming wrote:
                            while(!$found && list($key, $value) = each($line)) {
                            if(strtolower($ value) == strtolower($lin e_to_delete))
                            {
                            unset($line[$key]);
                            $found = true;
                            }
                            }
                            Could be neater as:

                            while (list($key, $value) = each($line))
                            {
                            if (strtolower($va lue) == strtolower($lin e_to_delete))
                            {
                            unset($line[$key]);
                            break;
                            }
                            }

                            or even:

                            foreach ($line as $key=>$value)
                            {
                            if (strcasecmp($va lue, $line_to_delete )==0)
                            {
                            unset($line[$key])
                            break;
                            }
                            }

                            However, I think what you actually want might be:

                            foreach ($line as $linenumber=>$v alue)
                            {
                            if ($line_to_delet e==$linenumber)
                            {
                            unset($line[$linenumber])
                            break;
                            }
                            }

                            --
                            Toby A Inkster BSc (Hons) ARCS
                            Contact Me ~ http://tobyinkster.co.uk/contact
                            Geek of ~ HTML/SQL/Perl/PHP/Python*/Apache/Linux

                            * = I'm getting there!

                            Comment

                            Working...