Re: HTML_QuickForm: HTML_select options with duplicate values
| From: | Massimiliano Arione | Date: | Fri, 27 Jan 2006 08:22:02 +0000 |
| Subject: | Re: HTML_QuickForm: HTML_select options with duplicate values | ||
| References: | 1 | Groups: | php.pear.general |
| Request: | Send a blank email to pear-general+get-22702@lists.php.net to get a copy of this message | ||
Markus Ernst wrote:
I would like to make a select box for countries with duplicate entries, [CUT]
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.You can use optgroups http://pear.php.net/bugs/bug.php?id=1283 Or, simpler: you can assign different values to your empty options (e.g. 1,2,3,etc) and treat these values like an empty string -- Massimiliano Arione http://garakkio.altervista.org