I'm trying to get the user to add certain info and store it like this
$heading1, $heading2, $heading3
I have created a loop like this:
for($i=1; $i< $sections; $i++) {
<input name="heading$i" type="text" >
}
Now the problem is that when I try to print the same info via a loop it only prints the numbers.
I have created a loop like this:
for($i=1; $i< $sections; $i++) {
print "$heading$i";
}
What do I need to do so that it prints the values for $heading1, $heading2 and so on in the loop.
Thanx!
use CGI;my $c = new CGI;
my ($x,$y);
# loop over each form input name
foreach $x($c->param) {
# skip if key not evaluate to 'heading'+(1 or more digits)
next if $x!~ /^heading\d+$/;
# put value in scalar context
$y = $c->param($x);
print $y; # print value
}
[edited by: netcommr at 8:26 am (utc) on July 7, 2003]
Here's what you need.
Variable variables [php.net]
Nick