Skip to content

Instantly share code, notes, and snippets.

@Zetzumarshen
Created May 18, 2016 01:12
Show Gist options
  • Save Zetzumarshen/277267ed63feb8566d82f7c93e987871 to your computer and use it in GitHub Desktop.
Save Zetzumarshen/277267ed63feb8566d82f7c93e987871 to your computer and use it in GitHub Desktop.
gotcha: automatically creates an array from name tag shenanigans
<form method="post" action="form.php">
<input name="person[male][first_name]" value="john" />
<input name="person[male][last_name]" value="smith" />
<input name="person[female][first_name]" value="jane" />
<input name="person[female][last_name]" value="jones" />
<input type="submit" value="Submit">
</form>
<?php
echo "output : \n";
var_dump($_POST);
/*
output :
array (size=1)
'person' =>
array (size=2)
'male' =>
array (size=2)
'first_name' => string 'john' (length=4)
'last_name' => string 'smith' (length=5)
'female' =>
array (size=2)
'first_name' => string 'jane' (length=4)
'last_name' => string 'jones' (length=5)
*/
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment