Script For Eliminating Duplicate Lines

Discussion in 'PHP' started by SNaRe, Feb 11, 2007.

  1. #1
    I need a php script to Eliminate Duplicate Lines.
    It can be from a txt file or from textbox.
    I tried to do it but i couldn't do . If you know a program that can do it it will be better
     
    SNaRe, Feb 11, 2007 IP
  2. krakjoe

    krakjoe Well-Known Member

    Messages:
    1,795
    Likes Received:
    141
    Best Answers:
    0
    Trophy Points:
    135
    #2
    
    $text = array_unique(split("\n", $text));
    foreach( $text as $data ){ if($data) : $new .= $data . "\n"; endif; }
    
    PHP:
    set text from the said data, that'll work, $text will contain old and $new will contain new
     
    krakjoe, Feb 11, 2007 IP