Page 1 of 1
[CLOSED] The formatlist() "d" parameter does not seem to be able to filter duplicate items, a list of one per line
Posted: 30 Apr 2024 10:48
by Norn
Code: Select all
$paper = <<<MENU
D:\test\1
D:\test\1.txt
D:\test\1.zip
D:\test\[2]
D:\test\[2](1).zip <-dupe
D:\test\[2].txt
D:\test\[2].zip
D:\test\[2]
D:\test\[2](1).zip <-dupe
D:\test\[2].txt
D:\test\[2].zip
MENU;
text $paper;
$paper = formatlist($paper, "d", <crlf>);
text $paper
It will work if you add the "s" parameter:
Code: Select all
$paper = <<<MENU
D:\test\1
D:\test\1.txt
D:\test\1.zip
D:\test\[2]
D:\test\[2](1).zip <-dupe
D:\test\[2].txt
D:\test\[2].zip
D:\test\[2]
D:\test\[2](1).zip <-dupe
D:\test\[2].txt
D:\test\[2].zip
MENU;
text $paper;
$paper = formatlist($paper, "sd", <crlf>);
text $paper
Re: The formatlist() "d" parameter does not seem to be able to filter duplicate items, a list of one per line
Posted: 30 Apr 2024 11:08
by highend
That's not a bug
For removing duplicates they can't be anywhere in the list but must follow each other. Your's aren't so you need to sort them first
Code: Select all
$paper = <<<MENU
D:\test\1
D:\test\1.txt
D:\test\1.zip
D:\test\[2]
D:\test\[2](1).zip <-dupe
D:\test\[2](1).zip <-dupe
D:\test\[2].txt
D:\test\[2].zip
D:\test\[2]
D:\test\[2].txt
D:\test\[2].zip
MENU;
$paper = formatlist($paper, "d", <crlf>);
text $paper;
Re: The formatlist() "d" parameter does not seem to be able to filter duplicate items, a list of one per line
Posted: 30 Apr 2024 11:23
by Norn
Removing duplicates only works on adjacent items, so if the list is not sorted non-adjacent duplicates remain in the list.
I saw the notes.
