# How to get dynamic variable name?

**URL:** <https://forum.kirupa.com/t/how-to-get-dynamic-variable-name/152184>\
**Category:** Uncategorized\
**Created:** [June 21, 2005, 11:03pm UTC](https://forum.kirupa.com/t/how-to-get-dynamic-variable-name/152184 "2005-06-21T23:03:08Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![pete\_zahut](https://avatars.discourse-cdn.com/v4/letter/p/91b2a8/32.png) [@pete\_zahut](https://forum.kirupa.com/u/pete_zahut)\
**Post date:** [June 21, 2005, 11:03pm UTC](https://forum.kirupa.com/t/how-to-get-dynamic-variable-name/152184/1 "2005-06-21T23:03:08Z")

</div>

Let me explain first:

I have a form that needs to be validated, but the form is built up dynamicly so ofcourse also the name of the inputs are dynamic, like so:

```php

foreach($values as $x) {
	echo "<td class='td_inspring2' align='center'><input name='q" .$i . "' type='text' value='" . $x . "' size='5'></td>";
} //end foreach 2

```

After submitting the form, it needs to be validated, but how can I a hold of my for example $q0 variable?

In the form I also send the $i value… so I tried something like this:

```php

//$aantal = $i out of form
for($i=0;$i<=$aantal-1;$i++) {
	$field = "q" . $i;
	$value = $_POST['field'];
	echo "Quantity : " . $value . "<br>"; 
}

```

But this returns nothing , it only outputs: "Quantity : "…

Thanx for your help, Pete :cross-eye
