Building a Variable concatenated with a variable

You have a number of items named as item_0, item_1, item_2

If you want to traverse them using a for loop, you have to build the variable.
The way to built it is :

for( $i = 0 ; $i < 3 ; $i++)
{
    $x = ${item$i}
    // Do Something with $x
}

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s