On Mon, 06 Aug 2001, Peter Lowe wrote:
> On Aug 06, Bug Database wrote:
> > ID: 12480
> > Updated by: andrei
> > Reported By: [EMAIL PROTECTED]
> > Old Status: Open
> > Status: Closed
> > Bug Type: Arrays related
> > Operating System: FreeBSD
> > PHP Version: 4.0.6
> > New Comment:
> > 
> > array_merge* functions are not meant to preserve numeric keys.
> 
> uhm, forgive me for being stupid, but why not? I was trying to use
> numeric keys to store the id of db records that didn't start at 0.
> using array_merge_recursive destroyed this information, so I have
> to store it in the array itself, which in turn means I can't do stuff
> like "if ($records[$id]['someval'])", or ksort on $records, or do
> "foreach ($records as $id => $values)" and other nice things like
> that after I've used array_merge_recursive.
> 
> and do you think, perhaps, it might be worth noting this in the man
> pages?

Because the idea behind merging two arrays (or at least my idea of it
that was the motivation for this function) is to preserve all elements
of the input arrays in the output one. If it worked as you suggested and
the input arrays had elements with the same numeric keys then only one
of those elements would appear in the output array, the rest would be
gone. That is how + operator works on array, by the way. So,
array_merge_* functions don't take numeric keys into account.

-Andrei

Politics is for the moment, an equation is for eternity.
       
                                   -- Albert Einstein

-- 
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to