how to delete same lines in file .txt but keep one (using php code) pls help
.text contain
=LDR 00000nam
=300 same text
=541 same text
=952 p000298
=LDR 00000nam
=300 same text
=541 same text
=952 p000299
=LDR 00000nam
=050 same text1
=082 same text1
=952 p002930
=LDR 00000nam
=050 same text1
=082 same text1
=952 p002931
out put
=LDR 00000nam
=300 same text
=541 same text
=952 p000298
=952 p000299
=LDR 00000nam
=050 same text1
=082 same text1
=952 p002930
=952 p002931
how to delete same lines in file .txt but keep one
Moderator: General Moderators
-
adnanrabbi
- Forum Newbie
- Posts: 4
- Joined: Fri Apr 22, 2011 9:49 am
-
ayazhaider
- Forum Newbie
- Posts: 5
- Joined: Fri Apr 22, 2011 11:18 am
Re: how to delete same lines in file .txt but keep one
Try Following if you want to delete duplicate lines from your text file
// Write your filename
$filename = 'ur_file.txt';
$text = array_unique(file($filename));
$f = @fopen($filename,'w+');
if ($f) {
fputs($f, join('',$text));
fclose($f);
}
@yAz
// Write your filename
$filename = 'ur_file.txt';
$text = array_unique(file($filename));
$f = @fopen($filename,'w+');
if ($f) {
fputs($f, join('',$text));
fclose($f);
}
@yAz
-
adnanrabbi
- Forum Newbie
- Posts: 4
- Joined: Fri Apr 22, 2011 9:49 am
Re: how to delete same lines in file .txt but keep one
thanks for quick reply
is it possible to search ignore following text if '=LDR 00000nam' text found just ignore no need to unique
as like this
=LDR 00000nam
=300 same text
=541 same text
=952 p000298
=952 p000299
=LDR 00000nam
=050 same text1
=082 same text1
=952 p002930
=952 p002931
is it possible to search ignore following text if '=LDR 00000nam' text found just ignore no need to unique
as like this
=LDR 00000nam
=300 same text
=541 same text
=952 p000298
=952 p000299
=LDR 00000nam
=050 same text1
=082 same text1
=952 p002930
=952 p002931
-
adnanrabbi
- Forum Newbie
- Posts: 4
- Joined: Fri Apr 22, 2011 9:49 am
Re: how to delete same lines in file .txt but keep one
Possible to add every sequence of =952%. add last sequence =LDR 00000nam
out put
=300 same text
=541 same text
=952 p000298
=952 p000299
=LDR 00000nam
=050 same text1
=082 same text1
=952 p002930
=952 p002931
=952 p002932
=LDR 00000nam
out put
=300 same text
=541 same text
=952 p000298
=952 p000299
=LDR 00000nam
=050 same text1
=082 same text1
=952 p002930
=952 p002931
=952 p002932
=LDR 00000nam