Assuming you are consistent with your numbering, that is, you always will use sequential numbering (1..10), you can combine the for loop with the eval function. For example, if you have 10 image/text combinations:

1 - The for loop is incrementing the value of $i by 1 each time a loop a completed, starting at 1 and ending at 10 (your number of text/image combinations). So the first time the loop is executed, $i = 1, the second time, $i = 2, etc.

2 - The eval statement is doing 2 things: 1) concatenating the first part of the variable name \$text and the value of $i(let's say that we're at the 3rd iteration of the loop, making $i = 3) to make $text$i; 2) "evaluating" the value of \$text$i, which converts \$text$i to $text3.

The backslash in front of the $text in the eval statement is necessary... otherwise, the eval statement would look for a scalar named $text. By placing the \ in front of $text, we are telling the eval statement that we want the concatenated result of literal $text$i ($text3), not the concatenated result of a variable named $text and $i.

Very Important: never, never, never use the eval statement with unchecked user form input! This could prove to be a gaping security hole. Always use variables you define implicitly, and if you really need to eval against form input, strip all / lines, and perform error checks on the data till you pass out. You wouldn't want someone to be able to eval and print /etc/passwd, would you?

If you don't get WebTechniques magazine in the mail (get it!), bookmark http://www.webtechniques.com/archives/2000/05/ and wait till May for the "Preserving Integrity" article by Matt Curtain. This article about security is a must read.