So you have 2 arrays one is holding the text of the numbered item in the array, and the other is holding a name that you want to be able to let the user change?
What you want to do can be done like this:
Your first loop only has one problem you should change:
name=" . $anyname[$x] . " value='"
to:
name=anyname[$x] value='"
So that when the form is submited you have a variable called $anyname that holds all of the fields.
In your second loop, you should use the count() of the $field array to determine the size of the loop (you should do this in the 1st one also). Then check if the field exists in $anyname and then make changes as appropriate:
for ($x = 1; $x = count($field); $x++) {
if (isset($anyname[$x])) {
if ($field[$x] != $anyname[$x]) {
$field[$x] = $anyname[$x];
}
}
else {
// user deleted the row store which row was deleted
$deletes[] = $x;
}
}
for (reset $deletes; $key = key($deletes); next($deletes)) {
// remove the $key row from $fields
}