Welcome Guest, Not a member yet? Register   Sign In
E-mail List Array
#1

[eluser]shenanigans01[/eluser]
I have a database where all the users have a field 'email' with their respective e-mail. What I would like to-do is load all the e-mails from the table (probably 30 of them) into an array and then e-mail them all.

I have the e-mail function, and I know how to select all the e-mails from the database, I'm having trouble getting them all into this format

[email protected], [email protected], [email protected] so I can use the email helper to send it out. Thoughts?
#2

[eluser]Madmartigan1[/eluser]
I assume you're using the CI email class.

Simple as this:

Code:
foreach ($emails as $email)
{
   $this->email->to($email);
}

I know in 2.0 you can just pass the array, not 100% sure in 1.7.2...

Code:
$this->email->to($emails);
#3

[eluser]tomcode[/eluser]
If You want the comma separated string from an array

Code:
$str = implode(', ', $emails);
#4

[eluser]Madmartigan1[/eluser]
It should be noted, to avoid confusion, that tomcode's example is not necessary when using the email library (or 'helper' as you put it).




Theme © iAndrew 2016 - Forum software by © MyBB