Solved

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

Posted on 2014-01-24
2
330 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Generating table dynamically is the most common issue faced by php developers.... So it seems there is a need of an article that explains the basic concept of generating tables dynamically. It just requires a basic knowledge of html and little maths…
Build an array called $myWeek which will hold the array elements Today, Yesterday and then builds up the rest of the week by the name of the day going back 1 week.   (CODE) (CODE) Then you just need to pass your date to the function. If i…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

734 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