Say there are form inputs posted with array-style names:
<input type="text" name="user[name]" value="John" />
<input type="text" name="user[email]" value="foo@example.org" />
<input type="checkbox" name="user[prefs][]" value="1" checked="checked" />
<input type="checkbox" name="user[prefs][]" value="2" checked="checked" />
<input type="text" name="other[example][var]" value="foo" />
Then $_POST would come back like this, print_r()‘d:
Array
(
[user] => Array
(
[name] => John
[email] => foo@example.org
[prefs] => Array
(
[0] => 1
[1] => 2
)
)
[other] => Array
(
[example] => Array
(
[var] => foo
)
)
)
The goal is to be able call a function, like this:
$form_values = form_values($_POST);
That would return an associative array with keys similar to the style of the original input names:
Array
(
[user[name]] => John
[user[email]] => foo@example.org
[user[prefs][]] => Array
(
[0] => 1
[1] => 2
)
[other[example][var]] => foo
)
This has been very challenging, and at this point my “wheels are spinning in the mud.” :-[
I’m not sure why you need to do this but if that following code can give you a hint :
http://codepad.org/UAo9qNwo