Jump to content

[SOLVED] Loop Help


JJ2K

Recommended Posts

Hi let's say I have a standard loop like:

for($i = 1; $i <10; $i++){
echo $i;
}

I want to create variables in this loop whose name consist of loop counter but don't know how to do this for example:

for($i = 1; $i <10; $i++){
$myField$i = $i;
}

So I want to create 10 variables called $myField1, $myField2 etc... How can I include the counter in the variable name as using the above would give an error?

 

Link to comment
https://forums.phpfreaks.com/topic/165235-solved-loop-help/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.