I'm not certain what you mean by saying that you cannot know ahead of time what the name-value pairs will be.
In reference to your example, this will work:
<?php
$person['contact_info']['fname'] = $_GET['contact_info.fname'];
$person['contact_info']['lname'] = $_GET['contact_info.middle'];
$person['contact_info']['middle'] = $_GET['contact_info.lname']);
?>
Not knowing the values in advance is a given - that's the way it is with user input.
You must know the keys in advance. Without this information you cannot know how to map values in $_GET
to values in $person
.
If you don't know the keys in advance you cannot solve this problem. If you don't know the keys in advance there is a serious flaw in the design of your software.
Jon Cram
2010-06-24 22:44:55