Forum Moderators: coopster
<?php
header("Content-Type: text/plain");
$lists = array();
$list = fopen("list.txt","r");
while(!feof($list))
{
$email = trim(fgets($list));
if ($email)
{
$parts = explode("@",$email);
// find the first list without an address for example.com ($parts[1])
$i = 1;
while(isset($lists[$i][$parts[1]])) $i++;
// ...and add the address
$lists[$i][$parts[1]] = $email;
}
}
//dump the lists
foreach($lists as $n => $emails)
{
print "List ".$n."\n\n";
print implode("\n",$emails)."\n\n";
}
?>