saghir69
09-09-2004, 07:17 AM
hi i'm creating a list of email adresses to send info abt my site, the list will be a txt file, i want to strip out any duplicates in the list. can any one tell me a way to do that in php?
i don't mind putting the addresses in a database if i have to!
Nilomedia
09-09-2004, 09:04 AM
If it's a safelist, i don't think it'd contain duplicates. what kind of list you arrange?
saghir69
09-09-2004, 09:37 AM
i'm creating a list from other related forum sites lol would that be classed as spam?
i've found this code from a site, will it work if i load my txt file in to an array and then save the output into another file called output.txt
<?php
// $old[0] = 1
// $old[1] = 1
// $old[2] = 2
// $old[3] = 1
// $old[4] = 2
$new = array();
for($i=0;$i<count($old);++$i){
if(in_array($old[$i], $new) != "true"){
$new[] = $old[$i];
}
}
//$new now contains:
//
//$new[0] = 1
//$new[1] = 2
?>
Nilomedia
09-09-2004, 10:23 AM
I'm not sure, but it's as clear as:
If people have choosed to be included in this list, and receive emails, then it's ok. but If they don't choose to receive that kind of emails, then it's spam which isn't legal.
saghir69
09-09-2004, 10:33 AM
but i won't do it to tooo many people, its very targeted lol
i shouldn't be saying this on a forum should i lol
Nilomedia
09-09-2004, 10:47 AM
Even if it's very targeted. since user hasn't approved this kind of bulk mailing, then it's not legal.
saghir69
09-09-2004, 10:55 AM
so wat happens if someone does do spaming?
Nilomedia
09-09-2004, 04:54 PM
law action will be made in such case. its against email policies.
sea otter
09-09-2004, 06:02 PM
how about just using array_unique() after you've loaded up the list? It returns a list with duplicates stripped.
http://www.php.net/manual/en/function.array-unique.php
Better yet, why not just do a one-pass load and check if the item is in the array as you are reading it in from disk? Faster and friendlier on memory.