By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,607 Members | 1,978 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,607 IT Pros & Developers. It's quick & easy.

array_merge bug ?

P: n/a
Hi,

This is my code :
########
$Table1 = array('test' =1, '432' =2) ;
$Table2 = array('test2' =1) ;

$Result = array_merge($Table1, $Table2) ;

echo "<pre>Table1=" . print_r($Table1, 1) . "</pre>";
echo "<pre>Table2=" . print_r($Table2, 1) . "</pre>";
echo "<pre>Result=" . print_r($Result, 1) . "</pre>";
########

And the result is :

########
Table1=Array
(
[test] =1
[432] =2
)
Table2=Array
(
[test2] =1
)
Result=Array
(
[test] =1
[0] =2
[test2] =1
)
########

The '432' key has become 0 !
Is it a bug (I couldn't find it over google) ?

How to keep the '432' key in the result ?

Thanks in advance,
// Cornelius
Aug 7 '07 #1
Share this Question
Share on Google+
1 Reply


P: n/a
I've just found the solution :

$Result = $Table1 + $Table2 ;

is better than :

$Result = array_merge($Table1, $Table2) ;

// Cornelius
Aug 7 '07 #2

This discussion thread is closed

Replies have been disabled for this discussion.