Page 1 of 1

Question... looping through an array passed via POST

Posted: Wed Mar 01, 2006 1:09 pm
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?

Posted: Wed Mar 01, 2006 1:16 pm
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

< > ( ) { } [ ]

Posted: Wed Mar 01, 2006 1:35 pm
by chrys
Yeah I can't foreach t hrough the array either. I think I know what the problem is

Posted: Wed Mar 01, 2006 1:53 pm
by feyd
lose the single quotes in the indices.