Re: QFC - Bug when storing the arrays in the container?

From: Date: Wed, 05 Nov 2003 12:55:22 +0000
Subject: Re: QFC - Bug when storing the arrays in the container?
References: 1  Groups: php.pear.general 
Request: Send a blank email to pear-general+get-8768@lists.php.net to get a copy of this message
<borz_off@cs.msu.su> wrote : > Hi! > > Mike Carter wrote: >> Got a real headache problem. Quickform controller is not storing my checkbox >> values correctly. >> The HTML generated by quickform is fine for the page. I have an array of >> checkboxes which are added to the page using: >> >> foreach($list as $key => $value){ >> $this->addElement('advcheckbox', "familyhistory[{$key}]", $value, >> null); >> } >> >> The array, $list, is a simple associative array of '2876587' => 'bob a >> job' >> style. > > > This looks like a problem with PHP's array_merge() function (it insists > on renumbering the numeric array keys), this was discussed in the list > before, I believe. That's correct. I suggest you use a letter or an underscore in front of your keys so they are considered as strings. This "feature" of array_merge() really sucks IMO, it just forces you to create your own array_merge alias, which is really slow, PHP apparently not being able to differentiate a string from an int when it comes to array keys. Bertrand Mansion Mamasam

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