Question: i have following while 

```
while($rs=mysqli_fetch_array($row))
{
 }

```

in each while execution there is one column which will have some ID lik 5 , 6 7, 8 

```
ID  Name    Intake  division_no      
1   5       1       2    
2   6       4       5

```

i have some varible name like txtin5, txtin6 

while looping in while i want to automatic assign intake value to that variable 
for ex in this case

```
        $txtin5 = 1
        $txtin6 = 4

```

i used this 

```
      $spvar = "txtin" ;
 $i=5;
    while {
    $$spvar.$i = rs['Intake']; 
 $i++;
    }  

```

i know this is wrong , but anyone could tell me the right way

Answer: 
Here's how you do variable variables in PHP:

```
${$spvar.$i} = $rs['Intake'];

```

However, I recommend that you avoid the need for this. Instead of variables `$txtin5` and `$txtin6`, why not make `$txtin` be an array, so you can use `$txtin[$i]`?
You can use arrays instead of what you did. Handling array is quite simple and easy.
SO your code will look like:

```
    while {
    $spvar[] = rs['Intake']; 
     }  

```

ANd if you want to have a associative array you can use:

```
   $i=5;
    while {
    $spvar[$i] = rs['Intake']; 
 $i++;
    } 

```