Re: HTML_QuickForm: HTML_select options with duplicate values

From: Date: Sat, 28 Jan 2006 22:03:37 +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-22714@lists.php.net to get a copy of this message
On 1/26/06, Markus Ernst <derernst@gmx.ch> wrote: > 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?? > Associative arrays associate a key with a value. By definition the keys in an array must be unique. -- Justin Patrin

« previous php.pear.general (#22714) next »