By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,406 Members | 1,470 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,406 IT Pros & Developers. It's quick & easy.

Arrays and Forms

P: n/a
I have two elements in a form , a text area (justification[]) and a hidden
field (prodID[])

I have the following code as a test:

foreach($_POST['justification'] as $reason) {
echo $reason."<br>";
}
foreach($_POST['prodID'] as $pID) {
echo $pID."<br>";
}

output
item reason
item reason 2
item reason 3
item reason 4

id1
id2
id3
id4

How can i edit the code as such so that the following out put is displayed:

item reason - id
item reason 2 - id2
item reason 3 - id3
item reason 4 - id4
Many Thanks for any help in advance

Craig

Jul 17 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Użytkownik "Craig Keightley" <do**@spam.me> napisał w wiadomo¶ci
news:42*********************@news-text.dial.pipex.com...
I have two elements in a form , a text area (justification[]) and a hidden
field (prodID[])
I have the following code as a test:
foreach($_POST['justification'] as $reason) {
echo $reason."<br>";
}
foreach($_POST['prodID'] as $pID) {
echo $pID."<br>";
}


for($i=0;$i<count($_POST['prodID']);$i++)
echo $_POST['justification'][$i].' - '.$_POST['prodID'][$i];

Jul 17 '05 #2

P: n/a
foreach ($_POST['justification'] as $id => $reason) {

echo $reason;
echo $_POST['prodID'][$id];

}

Jul 17 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.