I have a form that contains a number of fields with names item1, item2, item13, item43 etc, each time those fields are different because they are populated in the form with AJAX
foreach($_POST as $key => $value) { if (strstr($key, 'item')) { $x = str_replace('item','',$key); inserttag($value, $x); } }