Now I have duplicate emails lists name
I have a TXT file with a list of emails Now I have duplicate emails lists name Example:
sami@woo.com
sds@woo.com
sami@woo.com
asfi@woo.com
sami@woo.com
I want to show me only once every mail
And the result:
开发者_StackOverflow中文版sami@woo.com
sds@woo.com
asfi@woo.com
This code that I would love to get help:
<? Php
$ Username = $ argv [1];
$ File = file_get_contents (". / Emailist.txt");
$ Ex = explode ("\ r \ n", $ file);
for ($ i = 0; $ i <count ($ ex); $ i + +)
{
echo $ ex [$ i];
}
?>
tanks1
You could load the file into an array, using the file()
function -- it'll read the file, setting one item in the array for each line of the file.
And, then, use array_unique()
on that array, to remove duplicates.
You'd have some code that looks like this, I suppose :
$list = file('./Emailist.txt');
$list_unique = array_unique($list);
foreach ($list_unique as $mail) {
echo $mail;
}
You want to have a look at http://be.php.net/manual/en/function.array-unique.php
You can simply try this
$content = file('input.txt');
$result = array_unique($content);
print_r($result);
The following loads the file into an array, eliminates values and prints out the array.
<?php
$file = array_unique(file('emails.txt', FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES));
print_r($file);
?>
精彩评论