Need help with Array and Form

For whatever reason, I am a real WIMP when it comes to Arrays… :frowning:

So anyways…

I have a Form with 10 questions on it, and want to store each “Answer” in the $answerArray

The Questions (and User’s Answers) on my Form look like this…


	<!-- Question 1 -->
	<label for="question1">1.) Why did you decide to start your own business?</label>
	<textarea id="question1" name="answerArray[0]" cols="60" rows="8"><?php if (isset($answerArray[0])){echo htmlentities($answerArray[0], ENT_QUOTES);} ?></textarea>
	<?php
		if (!empty($errors['question1'])){
			echo '<br /><span class="error">' . $errors['question1'] . '</span>';
		}
	?>
	<br />

	<!-- Question 2 -->
	<label for="question2">2.) What advice would you share with others on what NOT to do?</label>
	<textarea id="question2" name="answerArray[1]" cols="60" rows="8"><?php if (isset($answerArray[1])){echo htmlentities($answerArray[1], ENT_QUOTES);} ?></textarea>
	<?php
		if (!empty($errors['question2'])){
			echo '<span class="error">' . $errors['question2'] . '</span>';
		}
	?>
	<br />

Assuming my Form is okay, how do I store all of the Responses into an Array in the $_POST array?

When my Form is submitted, I need a way to loop through each Answer and take the according action…

Thanks,

Debbie

When the form is submitted. PHP already builds an array for you.

They’re stored in $_POST[‘answerArray’][0], $_POST[‘answerArray’][1], etc.