Jump to content

Recommended Posts

I sounds easy and I am sure to some people it will be, but I am struggling and would appreciate some help.

I have an array of email addresses and in the array I like to add an ';' character to each email address so that I can use the array in the mail to function - I want to send bulk emails to everyone on my email list. Any one any idea how to go about this, I would appreciate it!!

Thanks

This is my code at the moment when i echo out the list the ; character must be at the end of each email address..

$mail = array();
$query = "SELECT * FROM email_list WHERE hear = 'Yes'";
$result = mysql_query($query) or die(mysql_error());
while ($row = mysql_fetch_object($result)) {
array_push ($mail, $row->email);
}
?>

<br><br><strong>Emails</strong><br>
<? foreach ($mail as $ma => $key){

echo $key; echo '<BR>'; }?>

I know I can echo it out like so
echo $key; echo ';'; echo '<BR>'; }?>

But I need to it be part of an array otherwise I can not use it in the mailto fucntion

Link to comment
https://forums.phpfreaks.com/topic/32575-solved-how-to-add-a-charater-to-an-array/
Share on other sites

Just make your array using....

[code=php:0]
while ($row = mysql_fetch_object($result)) {
  $array[] = $row->email; 
}
[/code]

Then, from the array, instead of using a loop create one long string of email addresses divided by ; by using...

[code=php:0]
$emails = implode(';',$array);
[/code]
implode the array:
[code]while ($row = mysql_fetch_object($result)) {
  array_push ($mail, $row->email); 
  }
// implodes the mail array to something like this:
// [email protected];[email protected];[email protected] etc
$addys = implode(';', $mail);[/code]

Umm, thorpe beat me :)
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

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.