How to get POST variable using regex like this:
$var = $_POST['foo?'];
or
$var = $_POST['foo\w{1}'];
Edit:
My form has many buttons with separate names: file1, file2, file3. When pressing a button, of course it pass file1 or file2, … I want to get the value using that name.
The easiest thing I can think of is this:
Replace
[0-9]in the regex with.to match any char, or whatever you need to see matched.Tested this out with an array that had the following keys
bar,zar,foo1,foo2,foo3, and it returnedarray('foo1' => 'val1','foo2' => 'val2','foo3' => 'val3'), which is what you need, I think.In response to your edit
The
$_POSTsuper-global can be a multi dimensional array, too:That way, you can easily loop through the files: