Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7704683
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T23:44:10+00:00 2026-05-31T23:44:10+00:00

I read all topics related to this question in stackoverflow and whole internet and

  • 0

I read all topics related to this question in stackoverflow and whole internet and cant find working sollution… Each owner has his item and when someone buy his item, owner gets an confirmation email, but when in cart is few same owner items, he gets several same email letters, so I need to remove dublicated array entries. I have tried to use DISTINCT and array_uniques functions but no luck. Any advices?

I have an array and function to send mail..

function email($mail_array) {
  foreach(array_unique($mail_array) as $field => $value) {
    $result = mysql_query("select email from users where $field='$value'");
    $row = mysql_fetch_array($result);


       $maail = mysql_real_escape_string($row['email']);
}
        $email_to = "".$maail."";



    // rest of mail formatting code

    // create email headers
    $headers = 'From: '.$email_from."\r\n" .
               'Reply-To: '.$email_from."\r\n" .
               'X-Mailer: PHP/' . phpversion();
    @mail($email_to, $email_subject, $email_message, $headers);
}


for ($i = 0; $i < $max; $i++) {
  $pid = $_SESSION['cart'][$i]['productid'];
  $owner = get_owner($pid);
  $mail_array = array(
    'name' => $owner
  );
  email($mail_array)  //call function to send mail          
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T23:44:11+00:00Added an answer on May 31, 2026 at 11:44 pm

    You are passing $mail_array with a single value to mail function,so multiple mails are being sent.
    Instead, make $owner as array() and push all owners name in it.But before that check whether the array has the same owner already using in_array().
    If owner is not there in the array then push it in the array otherwise do next iteration.
    And pass this array to mailing function.

        $mail_array = array();
        for ($i = 0; $i < $max; $i++) {
        $pid = $_SESSION['cart'][$i]['productid'];
        $owner = get_owner($pid);
        $mail_array = array_push($mail_array,$owner);    
        }
        email($mail_array)  //call function to send mail   
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I read all the questions related to this topic, and they all give reasons
First of all, I read all related topics and none of them answered my
I've read all the answers on to this questions and none of the solutions
I've read all recommended articles on SynchronizationContext, but there is one small question I
First - I read all similar topics and non of them work for me.
I browsed through all kinds of post related to this topic but the answers
I've read all topics re. SASS + RoR, but there are no answers for
I've read some topics about this, but still can't figure out how I can
I read through a lot of circular dependency topics but all of them seem
i've already read all topics here and on google about redirection but i'm a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.