gabrielkolbe Posted January 2, 2007 Share Posted January 2, 2007 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!!ThanksThis 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 More sharing options...
trq Posted January 2, 2007 Share Posted January 2, 2007 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] Link to comment https://forums.phpfreaks.com/topic/32575-solved-how-to-add-a-charater-to-an-array/#findComment-151470 Share on other sites More sharing options...
wildteen88 Posted January 2, 2007 Share Posted January 2, 2007 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 :) Link to comment https://forums.phpfreaks.com/topic/32575-solved-how-to-add-a-charater-to-an-array/#findComment-151471 Share on other sites More sharing options...
gabrielkolbe Posted January 2, 2007 Author Share Posted January 2, 2007 thanks, but this does not really help me. Because I end up with a string not a array.. Link to comment https://forums.phpfreaks.com/topic/32575-solved-how-to-add-a-charater-to-an-array/#findComment-151518 Share on other sites More sharing options...
gabrielkolbe Posted January 2, 2007 Author Share Posted January 2, 2007 found the solution ..thanks guys!!! array_push ($mail, $row->email); $emails = implode('; ',$mail); $emailer = explode(" ", $emails); Link to comment https://forums.phpfreaks.com/topic/32575-solved-how-to-add-a-charater-to-an-array/#findComment-151526 Share on other sites More sharing options...
trq Posted January 2, 2007 Share Posted January 2, 2007 If you really want to keep an array just use....[code=php:0]while ($row = mysql_fetch_object($result)) { array_push ($mail, $row->email.';'); }[/code] Link to comment https://forums.phpfreaks.com/topic/32575-solved-how-to-add-a-charater-to-an-array/#findComment-151527 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.