Codeigniter convert array to string

I think this is a really stupid question, but I'm trying to get all the email addresses from a database into a string so I can send an email to everyone in the database (it never gets bigger than 25 emails) by using $list ($this->email->to($list)), instead of using a foreach which is slow because it has to send each email.

Here's a simple test that shows there are 8 rows, but $list->result_array() just displays Array and print_r($list) shows all the information.

My question is how do I into a string ($list) that I can use for $this->email->to($list) ?
function get_emails() {
        $list = $this->db->get('users');
        echo $list->num_rows() . '<br />';
        echo $list->result_array() . '<br />';
        print_r($list) . '<br />';

Open in new window

Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

You can't just print an array this way. You could use the implode function if you array was only 1 dimensionnal :

$adresses = implode(',' , $list->result_array());
//$adresses will then be sthg like ","

But in codeIgniter, your array will be 2 dimensionnal. So you have to do a loop like :
$adresses = '';
foreach($list->result_array() as $adr){
$adresses .= $adr['sql_adr_field_name'] . ',' ;

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Web Frameworks

From novice to tech pro — start learning today.