I have a form with multiple textboxes which are created dynamically, now all these textboxes are of same name lets say txt
, now is there any way that when form processing happens we could read all the text boxes values using $_POST
method, which are of so called same name. If possible how?
相关问题
- Views base64 encoded blob in HTML with PHP
- Laravel Option Select - Default Issue
- Carriage Return (ASCII chr 13) is missing from tex
- PHP Recursively File Folder Scan Sorted by Modific
- Can php detect if javascript is on or not?
Create your text box with names txt[]
And in PHP read them as
You have to name your textboxes
txt[]
so PHP creates a numerically indexed array for you:Otherwise the last textbox' value will overwrite all other values!
You could also create associative arrays:
But then you have to take care of the names yourself instead of letting PHP doing it.
If you want name, you could name the input with
txt[name1]
, then you could get it value from$_POST['txt']['name1']
.$_POST['txt']
will be an associative array.