SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Guru Richi's Avatar
    Join Date
    Jul 2001
    Location
    Hu,Bp.
    Posts
    842
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Write & delete from file , HOW ?!

    Hi all !

    any1 can tell me how to delete from file 1 line or 1 command, which is inserted via php ?

    i know how to write to file,but i don`t think is the right way if i wanna to deleted, coz as i think i must use Buffer,but i don`t know how !

    thx for ur time and help ..

  2. #2
    You talkin to me? Anarchos's Avatar
    Join Date
    Oct 2000
    Location
    Austin, TX
    Posts
    1,438
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    while($line = fgets($buffer,4096)){
    $line = chop($line);
    if ($line != "blah")
    $data[] = $line;
    }

    This'll load all lines except for ones that equal blah (you can use regex if you want). Then you just reopen the file in write mode and output the $data array.
    ck :: bringing chris to the masses.

  3. #3
    SitePoint Guru Richi's Avatar
    Join Date
    Jul 2001
    Location
    Hu,Bp.
    Posts
    842
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    ok but how delete a line, not just a word ?
    lets say :
    i have news script,wich write the news to *.dat file (head,news) , until now is ok, but how can i delete it ?!!!


Bookmarks

Posting Permissions

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