RE: [PHP] Variable in a variable.
| From: | Christensen, BruceX R | Date: | Tue, 01 Aug 2000 21:54:28 +0000 |
| Subject: | RE: [PHP] Variable in a variable. | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-9576@lists.php.net to get a copy of this message | ||
It would be much easier if you used PHP's array syntax in the form:
<input name="name[1]">
<input name="year[1]">
<input name="url[1]">
<input name="name[2]">
<input name="year[2]">
<input name="url[2]">
etc.
Then you could just do:
foreach($name as $idx => $value){
echo "Name is $value";
echo "Year is $year[$idx]";
echo "URL is $url[$idx]";
}
(untested)
--Bruce
Bruce Christensen
Intel Corporation
brucex.r.christensen@intel.com
-----Original Message-----
From: Milton Thomas [mailto:millie@colis.com]
Sent: Tuesday, August 01, 2000 4:47 PM
To: plist
Subject: [PHP] Variable in a variable.
I have some variables in a form
they are name, year, url.
I have 10 rows of these variables.
so the are named name1, year1, url1, name2, year2, url2.....
when i click submit i want to create a loop from 1 to 10 and read these
variables.
eg.
for($x=1;$x<=10;$x++){
$name_var = "$"."name".$x
echo $$name_var
}
what i am expecting is..
eg name1 ="milton"
$name_var="$name1";
$$name_var ="milton"
this worked in PHP3
I cant get it to work now.
any suggestion
Milton C. Thomas
Freelance Web Developer
Resume : http://resumes.dice.com/millie
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net
For additional commands, e-mail: php-general-help@lists.php.net
To contact the list administrators, e-mail: php-list-admin@lists.php.net