Re: For loops adding
| From: | Steve Edberg | Date: | Wed, 19 Jul 2000 16:51:38 +0000 |
| Subject: | Re: For loops adding | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-7310@lists.php.net to get a copy of this message | ||
At 3:54 PM +0100 7/19/00, Matt Williams wrote:
Hi I'm using a for loop to display the results of a form. Basically the user chooses how many times they want the form repeating, they then fill in the form then submit it. What I need to then be able to do is display the results back to them. So for example I have loop like this to display the fields. for ($i=0;$i<$choice;$i++) { echo "<input type=\"text\" name=\"text$i\"> } if $choice was 2 it would obviously give me 2 text boxes named0 and text1 When I come to process the field I am again using the for loop to display the results but I can't find a way to display the current value of $i from the loop so if I try to print echo $text.$i I get 0 etc. without it giving me the proper value How do I "add" these together so it would give me the current value of $text according to $i.Try echo ${"text".$i} See http://www.php.net/manual/language.variables.variable.php -steve +--- unix and cats: -----------------------------------------------------+
| Steve Edberg University of California, Davis | | sbedberg@ucdavis.edu Computer Consultant | | http://aesric.ucdavis.edu/ http://pgfsun.ucdavis.edu |+----------------------- hard to befriend, but then friends for life! ---+