Question: This doesn't work, what I want it to do is go through the posts until there are no more item\_name1 and they increment to item\_name2 - item\_name3 ect.... does not spit out an error, just doesn't do what it's suppose to, checking if someone are here sees one. Thanks

```
if(isset($_POST['item_name1'])){
    for($i = 1; $i < 9999; $i++) {
    if(isset($_POST['item_name$i'])){
    do this thing
    }
    else{
    $i = 10000;
    }
    }
    }

```

Answer: 
correct $\_POST['item\_name$i'] inside the loop
make it something like this and try again

```

    if(isset($_POST['item_name'.$i]))
    {
    do something;
    }

```

I apologize if I am wrong
You are dealing with a classic `$_POST` anti-pattern. Chances are what you should be doing is posting an array of data. This starts by proper input naming. May I suggest something like this:

```
<input name="item_name[1][]" ... />
<input name="item_name[1][]" ... />
<input name="item_name[2][]" ... />
<input name="item_name[2][]" ... />
<input name="item_name[2][]" ... />
<input name="item_name[3][]" ... />

```

By using this sort of naming convention, you can post a multi-dimensional array to `$_POST['item_name']` that is ready for use without you needing to massage the data before working with it.

For example, in this case you would get an array like this for `$_POST['item_name']`

```
[
  0 => [
    0 => "some value",
    1 => "some other value"
  ],
  1 => [
    0 => "yet another value",
    1 => "foo",
    2 => "bar"
  ],
  3 => [
    0 => "last one"
  ]
]

```

Really anytime you catch yourself wanting to increment values within the input name like that, you can almost bet that using array notation is a better approach.

For example, with this approach you don't need to loop through a bunch of values for `$i` because this index MIGHT be present in `item_name$i`. Instead you would already have the array with all appropriate `item_name[i]` values already populated.