HTML_QuickForm: HTML_select options with duplicate values
| From: | Markus Ernst | Date: | Thu, 26 Jan 2006 22:10:49 +0000 |
| Subject: | HTML_QuickForm: HTML_select options with duplicate values | ||
| Groups: | php.pear.general | ||
| Request: | Send a blank email to pear-general+get-22701@lists.php.net to get a copy of this message | ||
Hi
I would like to make a select box for countries with duplicate entries, such as
<option value=""></option>
<option value="DE">Germany</option>
<option value="AT">Austria</option>
<option value="CH">Switzerland</option>
<option value="">-------</option>
<option value="AF">Afghanistan</option>
...
Country List from I18NV2 follows here.
Note that the empty line and the separator share the same value (""), and also the preferred countries at the top should be found also at the appropriate place in the list below.
Now the select element in QuickForm expects an associative array of the option elements. This seems to be a problem, as PHP does not seem to allow duplicate keys in an associative array?? Please correct me if I am wrong, but according to the manual and my experience, array_merge will only keep the last element with the same key, while using the + operator to append elements will only keep the first one.
Is there a method in PHP to keep the duplicate array keys? Or is there a possibility to pass an array of the form
array(array("DE", "Germany"), array("AT", "Austria))
to Quickform?
Or am I missing something very obvious??
Thanks for a hint
Markus