Solved

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

Posted on 2014-01-24
2
323 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Popularity Can Be Measured Sometimes we deal with questions of popularity, and we need a way to collect opinions from our clients.  This article shows a simple teaching example of how we might elect a favorite color by letting our clients vote for …
Foreword (July, 2015) Since I first wrote this article, years ago, a great many more people have begun using the internet.  They are coming online from every part of the globe, learning, reading, shopping and spending money at an ever-increasing ra…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

911 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now