Solved

PHP - find records in one array that rea not found in another array?

Posted on 2014-01-24
2
324 Views
Last Modified: 2014-01-24
Hi,
I need to find records that are in the $remote_emails array that don't already exist in the $local_emails array.

Is there an easy way to do this?

Thanks

				echo "Local Emails</br>";
				$local_emails = array('abc@hotmail.com','john@hotmail.com','peter@hotmail.com','peter3@hotmail.com','peter4@hotmail.com','peters@hotmail.com');
				print_r($local_emails);
                
                echo "</br>";
				echo "Remote Emails</br>";
                
                $remote_emails = array('andrew@hotmail.com', 'peter@hotmail.com','peter_62@hotmail.com');
				print_r($remote_emails);
				
				
				//if email address from $remote_emails array does not exists in $local_emails array then echo it here

Open in new window

0
Comment
Question by:sabecs
2 Comments
 
LVL 58

Accepted Solution

by:
Gary earned 500 total points
ID: 39807953
http://ie2.php.net/array_diff

$difference = array_diff($remote_emails, $local_emails );

var_dump($result);
0
 

Author Closing Comment

by:sabecs
ID: 39808179
Thanks Cathal.
0

Featured Post

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Deprecated and Headed for the Dustbin By now, you have probably heard that some PHP features, while convenient, can also cause PHP security problems.  This article discusses one of those, called register_globals.  It is a thing you do not want.  …
Part of the Global Positioning System A geocode (https://developers.google.com/maps/documentation/geocoding/) is the major subset of a GPS coordinate (http://en.wikipedia.org/wiki/Global_Positioning_System), the other parts being the altitude and t…
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

785 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question