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.

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));
?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.