Solved

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

Posted on 2014-01-24
2
320 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
Comment Utility
http://ie2.php.net/array_diff

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

var_dump($result);
0
 

Author Closing Comment

by:sabecs
Comment Utility
Thanks Cathal.
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Introduction HTML checkboxes provide the perfect way for a web developer to receive client input when the client's options might be none, one or many.  But the PHP code for processing the checkboxes can be confusing at first.  What if a checkbox is…
This article discusses four methods for overlaying images in a container on a web page
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

772 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

11 Experts available now in Live!

Get 1:1 Help Now