# How to increment a variable?

**URL:** <https://forum.kirupa.com/t/how-to-increment-a-variable/180950>\
**Category:** programming\
**Created:** [March 4, 2006, 10:35pm UTC](https://forum.kirupa.com/t/how-to-increment-a-variable/180950 "2006-03-04T22:35:10Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![endy](https://avatars.discourse-cdn.com/v4/letter/e/f19dbf/32.png) [@endy](https://forum.kirupa.com/u/endy)\
**Post date:** [March 4, 2006, 10:35pm UTC](https://forum.kirupa.com/t/how-to-increment-a-variable/180950/1 "2006-03-04T22:35:10Z")

</div>

Hello,  
I am trying to use a “while” loop to create a bunch of variables, however it doesnt seem to be working. Is there a way to concatenate a variable name with another variable? Here is what I am trying to do:

```auto
$i=0
while($i<5) {
$my_var.$i="something";
$i++;
}

```

So I just want to get a series of variables ($my\_var1, $my\_var2, $my\_var3,…) that are all equal to “something”;

Is it possable?  
THanks!
