View Full Version : foreach loops

02-25-2008, 06:59 AM
I have the following setup. I want to pass an array from the lower foreach loop to the upper foreach loop when I submit the former. I don't really know what I'm doing -relying more on logic than knowledge of syntax - but this doesn't work. What am I doing wrong? Thanks guys.

foreach ($_POST['emailto'] as $send) {
echo $send;


foreach ($_POST['email'] as $sendto) {
echo("<input type='hidden' name='emailto[".$i."]' value='".$sendto."'>");
// and other stuff that works OK

02-25-2008, 09:55 AM
I dont think you can have multiple values for one array key.... So for example when you take $_POST['email'] there will only be one value.... you cannot run a foreach command on that.

Try changing your code so that you run a foreach on only the $_POST. and not on individual keys.


foreach ($_POST as $value){
foreach ($_POST['some_value']){

or just try re-evaluating your code.

02-25-2008, 01:18 PM
Yeah, that didn't work out at all so I completely changed the code. Thanks anyway.