...

View Full Version : Some array help please



seco
12-03-2010, 02:51 PM
So here is my question, hoefully I can get and answer.

I have a form with fields like so, I'll use some basic values



<input type="text" name="C_0[]" value="entered 1" />
<input type="text" name="C_0[]" value="entered 1" />
<input type="text" name="C_0[]" value="entered 1" />
<input type="text" name="C_1[]" value="entered 2" />
<input type="text" name="C_1[]" value="entered 2" />
<input type="text" name="C_1[]" value="entered 2" />
<input type="text" name="C_2[]" value="entered 3" />
<input type="text" name="C_2[]" value="entered 3" />
<input type="text" name="C_2[]" value="entered 3" />


Now I figured out how to get the POST data to show like so



entered 1, entered 1, entered 1
entered 2, entered 2, entered 2
entered 3, entered 3, entered 3


Now my question is, how can i get the post data to show like so



entered 1, entered 2, entered 3
entered 1, entered 2, entered 3
entered 1, entered 2, entered 3


im at a complete loss with this, google hasent helped me and Im not really sure what to be searching for in the first place.

MattF
12-03-2010, 04:04 PM
foreach ($_POST['C_0'] as $key => $val)
{
print($val.', '.$_POST['C_1'][$key].', '.$_POST['C_2'][$key]);
}

seco
12-03-2010, 08:54 PM
foreach ($_POST['C_0'] as $key => $val)
{
print($val.', '.$_POST['C_1'][$key].', '.$_POST['C_2'][$key]);
}


so its this simple? i didnt realize you could nest them inside the foreach. man i feel like a idiot, lol thanks matt



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum