extracting e-mail lists

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
eektech909
Forum Commoner
Posts: 34
Joined: Fri Jun 09, 2006 3:59 pm

extracting e-mail lists

Post by eektech909 »

Is there a way to take a list of e-mail addresses (text1.txt) and remove all of them from a different list (text2.txt)?
Begby
Forum Regular
Posts: 575
Joined: Wed Dec 13, 2006 10:28 am

Post by Begby »

Yes.

Have you tried anything yet? You have to open the files, parse the data into arrays, then remove the items that are in array1 from array2.
ianhull
Forum Contributor
Posts: 310
Joined: Tue Jun 14, 2005 10:04 am
Location: Hull England UK

Post by ianhull »

Try this,

Code: Select all


<?php

$email_arr1 = array("info@domain.com", "info@dominan.net");

$email_arr2 = array("info@domain.co.uk", "info@domain.net");

foreach($email_arr1 as $key => $val){
if (in_array($val, $email_arr2)) {
    echo "email matched: " . $val;
    //perform your removal
}
};

?>

Not tested but should work
Post Reply