Hi
Here is another way
$x = 1;
while($x < 5):
         $index = "name".$x;
         $name = $$index;
         echo $name."<br>";
endwhile;
had troubles with echo and $$variable, thats why the extra step....habit
Tom



At 10:58 AM 23/04/01 +1000, Chris Aitken wrote:
>Hi
>
>Just a quick puzzle I cant seem to get around at the moment...
>
>Im trying to create a loop that increments the string name by a digit. For 
>example, if I had the following 4 strings submitted to a script.....
>
>$name1
>$name2
>$name3
>$name4
>
>What I want to do is create a while loop that will print out the above 4 
>strings, incrementing the number part of string automatically.
>
>while($count<4) {
>     $count=$count+1;
>     echo"$increased_string_name\n";
>}
>
>But I just cant seem to work out how to increment the string name to 
>display it.
>
>Any assistance on this would be great. I have a feeling that there is a 
>better method of attacking this but im only new to PHP and dont know it yet.
>
>
>
>Thanks
>
>
>Chris
>
>
>--
>PHP General Mailing List (http://www.php.net/)
>To unsubscribe, e-mail: [EMAIL PROTECTED]
>For additional commands, e-mail: [EMAIL PROTECTED]
>To contact the list administrators, e-mail: [EMAIL PROTECTED]


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to