View Full Version : Help with FOREACH... with an example

12-10-2008, 08:17 PM
Ok, it must be that I am tired as I can not figure out the simple thing that I have done so many times. FOREACH.

In my simple example, all I want is to print out all the values from the array.

<form action="testarray.php" method="post">
<input type="text" name="toolname[]"><br />
<input type="text" name="toolname[]"><br />
<input type="text" name="toolname[]">
<input type="submit" name="submit" value="submit"></form>

$toolname = $_POST['toolname'];


foreach ($toolname as $value) {
echo '<p>' . $toolname[$value] . '</p>';

The Array prints out fine but the foreach part doesn't work...

And I have no idea why my php code appears on one long line in this post, sorry.

12-10-2008, 08:20 PM
$toolname = $_POST['toolname'];
foreach ($toolname as $value)
echo '<p>' . $value . '</p>';

12-10-2008, 08:29 PM
LOL, I knew it was something real stupid that I overlooked. Oh well... told you I was tired.

Thanks a lot. :thumbsup: