Jump to content


This topic is now archived and is closed to further replies.


Comparing two arrays and sending mail

Recommended Posts


I am currently trying to build a small mailing list. In the mysql table storing the subscribers info (called members), I have a field called groups. This field is populated from checklists and using serialize to store the values. (I know I shouldnt do it this way, but it has worked for the rest of the mailing list).

I have created the page to send mail and on that the users checks what groups they want to send to. These results are sent to the form with $_POST['groups_input'].

What I need help with is taking the array from the _POST, breaking it down by individual group, and comparing each of those to the array stored in the groups database. If there is a match than it would send the email.

Im guessing to start I need to do something like this to break down the _POST into individual groups and put all the code in between the brackets :

$selected_list = unserialize($groups_selected);
foreach($selected_list as $list_group)


Im new with all this and help would be very appreciated!

Share this post

Link to post
Share on other sites
Something like this?


$their_POST = array(1, 4, 99);
$database_result = array(
1 => array('aaron', 'bob'),
2 => array('bob', 'laura'),
3 => array('jean', 'john'),
4 => array('jim', 'bill'),

foreach ($their_POST as $key => $group_number) {
if (is_array($emails = $database_result[$group_number])) {
echo join(', ', $emails), '<br/>';
else {
echo 'Invalid group</br>';



Share this post

Link to post
Share on other sites


Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.