Hooch Posted October 18, 2008 Share Posted October 18, 2008 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. Quote Link to comment https://forums.phpfreaks.com/topic/128926-solved-put-an-array-to-a-single-variable/ Share on other sites More sharing options...
.josh Posted October 18, 2008 Share Posted October 18, 2008 implode Quote Link to comment https://forums.phpfreaks.com/topic/128926-solved-put-an-array-to-a-single-variable/#findComment-668442 Share on other sites More sharing options...
Guest Xanza Posted October 18, 2008 Share Posted October 18, 2008 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)); ?> Quote Link to comment https://forums.phpfreaks.com/topic/128926-solved-put-an-array-to-a-single-variable/#findComment-668448 Share on other sites More sharing options...
Hooch Posted October 18, 2008 Author Share Posted October 18, 2008 Ah.... Thank you. Worked like a charm!! Quote Link to comment https://forums.phpfreaks.com/topic/128926-solved-put-an-array-to-a-single-variable/#findComment-668465 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.