Jump to content

[SOLVED] Put an array to a single variable


Hooch

Recommended Posts

Hello all.

I have a page that you "checkbox" emails then click submit.

The next page is to type a message and send it on it's merry way.

This page receives all those emails with the following code

	while (list ($key,$val) = @each ($id))
{
echo "$val;";
}

Can I get these emails (could be as many as 80) into a variable.

Basically I need $send_to to equal those emails from the above code.

(The code above will print out the emails perfectly)

Thank you for any help.

Link to comment
Share on other sites

I agree implode() is the easiest way to accomplish this.

 

$send_to = implode(",", $_POST['emails']);

 

Really good example of a possible application for you to use: (from php.net)

 

<?php
function array_implode($arrays, &$target = array()) {
    foreach ($arrays as $item) {
        if (is_array($item)) {
            array_implode($item, $target);
        } else {
            $target[] = $item;
        }
    }
    return $target;
}

$a = array('a', 'b', array('c', 'd', array('e'), 'f'), 'g', array('h'));

echo join(' - ', array_implode($a));
?>

Link to comment
Share on other sites

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.