Hi, Thanks for replying. I tried that and have 2 numbers like so:
<input name="id[sh123]" type="hidden" value="32"> <input name="id[sh1sd]" type="hidden" value="563">
and tried to echo it like so: <?php $id=$_POST['id']; foreach($_POST['id'] AS $row) echo $row; ?> Echo of one is <?php echo $row[0]; ?> and echo of two is:<b> <?php echo $row[1]; ?></b><br><br> Echo of one is <?php echo $id[0]; ?> and echo of two is:<b> <?php echo $id[1]; ?></b>
the output i got was: ****************** 32563Echo of one is 5 and echo of two is: 6
Echo of one is and echo of two is: *****************
AS you can see its totally wrong.Any other ideas?
No... you're getting exactly what you ask for. You rely on this list to much.
1. You have no braces so your foreach() is taking the next line as the part that should be executed on each loop.
2. Loop 1 sets $row = 32. Then it's displayed
3. Loop 2 sets $row = 563. Then it's displayed
4. So now $row = 563. When you display $row[0], you're asking for the first character of $row, so 5 is displayed. $row[1] displays 6.
5. Now you go back to $id. Well, $id = array('sh123' => 32, 'sh1sd' => 563). So, when you try to display $id[0] and $id[1], there are no cooresponding values, so nothing is displayed.
Now, how do you do this correctly?
foreach($_POST['id'] as $key => $value) { echo "The random key is $key, the value is $value.<br />"; }
which will give you:
The random key is sh123, the value is 32. The random key is sh1sd, the value is 563.
What do you want, besides that?
-- ---John Holmes...
Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/
PHP|Architect: A magazine for PHP Professionals – www.phparch.com
-- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php