|
Posted by usenet on 12/05/05 02:00
PHP 4.2.2
Apache 2.0.40
My script receives values for several values :
_POST["c1"] = "a"
_POST["c2"] = "b"
_POST["c3"] = "c"
_POST["c4"] = "d"
The number of vars posted changes however, so I need to access the $_POST
variables using a loop. I figured I could accomplish using one of these
assignments, but apparently I'm wrong :
$i = 1;
$h = 7; // this varies, based on a database record
while ($i <= $h) {
$c{$i} = $_POST['$c{$i}'];
// or
$c{$i} = $_POST[$c{$i}];
// or
$postval = "$" . "c" . $i;
$c{$i} = $_POST[$postval];
// or
$postval = "$" . "c" . $i;
$c{$i} = $_POST['$postval'];
// or, what the heck, why not try this?
$postval = "$" . "c" . $i;
$c{$i} = $_POST[eval($postval)];
$i++;
}
Clearly, I'm trying almost anything at this point . . . but I must be missing
something obvious, and I can't figure out the narrow Google search to find the
answer. Can anyone suggest the solution ?
Any and all advice will be greatly appreciated.
Navigation:
[Reply to this message]
|