RE: [PHP] Making variables with an iteration?
| From: | SCALES, Andrew | Date: | Mon, 06 Dec 2004 14:55:09 +0000 |
| Subject: | RE: [PHP] Making variables with an iteration? | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-203591@lists.php.net to get a copy of this message | ||
I might be wrong but I don't think you can reference variable names in that
way. You probably need something like this:
for ($j=1, $j<5, $j++)
{
$tempChoice = "choice" . $j;
$$tempChoice = $_POST['choice'.$j];
}
And that should create your $choice1.. $choice2 etc.
Andy.
-----Original Message-----
From: Robert Sossomon [mailto:robert_sossomon@ncsu.edu]
Sent: Monday, 06 December 2004 14:29
To: PHP General List
Subject: [PHP] Making variables with an iteration?
I've got some inputs, which I need to tie down to only have 4 come in from.
The
javascript to verify it is working somewhat, however I want to create the
parsing script to loop through the inputs (choice) and then dump them into
$choice1, $choice2, $choice3, $choice4 respectively.
I have to use checkboxes with different names with the javascript checkers I
am
using, since they seem to be working, however I can't seem to get the PHP in
the
parser to write the variables. Any ideas?
<SNIP>
for ($j=1, $j<5, $j++)
{
$choices.$j= $_POST['choice'.$i];
}
Thanks,
Robert
--
Robert Sossomon, Business and Technology Application Technician
4-H Youth Development Department
200 Ricks Hall, Campus Box 7606
N.C. State University
Raleigh NC 27695-7606
Phone: 919/515-8474
Fax: 919/515-7812
robert_sossomon@ncsu.edu
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php