Question... looping through an array passed via POST

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
chrys
Forum Contributor
Posts: 118
Joined: Tue Oct 04, 2005 9:41 am
Location: West Roxbury, MA (Boston)

Question... looping through an array passed via POST

Post by chrys »

Ok, I've never had this problem before.

Basically, I have some tabular data, and every row has a checkbox

So you can check like 5 boxes and commit an action on them...

Code: Select all

<tr bgcolor="#dddddd">
		<td><input type="checkbox" name="checked['43914']" value="1" style="margin: 0px;" /></td>
	</tr>
	<tr bgcolor="#eeeeee">
		<td><input type="checkbox" name="checked['43999']" value="1" style="margin: 0px;" /></td>
	</tr>
	<tr bgcolor="#dddddd">
		<td><input type="checkbox" name="checked['44326']" value="1" style="margin: 0px;" /></td>
	</tr>
Something like that, where the value is the ID of the record.

The problem is, when I print_r($_POST['checked']) all that is outputted is "Array" which is friggin bizarre.

So basically when I loop through the array nothing happens. Any ideas?
User avatar
nickman013
Forum Regular
Posts: 764
Joined: Sun Aug 14, 2005 12:02 am
Location: Long Island, New York

Post by nickman013 »

Code: Select all

$fix = array("<",">","(",")","{","}","[","]");
foreach ($fix as $current)
echo $current.' ';
Is this what you mean. This will preview all the stuff in the array in this format

< > ( ) { } [ ]
User avatar
chrys
Forum Contributor
Posts: 118
Joined: Tue Oct 04, 2005 9:41 am
Location: West Roxbury, MA (Boston)

Post by chrys »

Yeah I can't foreach t hrough the array either. I think I know what the problem is
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

lose the single quotes in the indices.
Post Reply