From:             youri dot essa at gmail dot com
Operating system: Linux
PHP version:      5.4.10
Package:          Arrays related
Bug Type:         Bug
Bug description:array_merge memorry issues.

Description:
------------
---
>From manual page:
http://www.php.net/function.array-merge#refsect1-function.array-
merge-description
---


Test script:
---------------
foreach($cols as $key => &$value) {
        if(array_key_exists($key, $fields)) {
                $value = array_merge($fields[$key], $value);
        }
}
                        
foreach($fields as $key => $value) {
        if(!array_key_exists($key, $cols)) {
                $cols[$key] = $value;
        }
}

Expected result:
----------------
Expected result is that col becomes is an array with all the values that
where 
already defined added with the values from fields.

Actual result:
--------------
The sub-array in cols wich was merged with the same sub-array in fields
becomes 
overwritten everytime the next foreach statement accesses the value $value,
witch 
result. the fix for this is to have a diffrent name for the array merging,
this 
leads me to belive that array_merge keeps re-evaluating the values.

-- 
Edit bug report at https://bugs.php.net/bug.php?id=64005&edit=1
-- 
Try a snapshot (PHP 5.4):   
https://bugs.php.net/fix.php?id=64005&r=trysnapshot54
Try a snapshot (PHP 5.3):   
https://bugs.php.net/fix.php?id=64005&r=trysnapshot53
Try a snapshot (trunk):     
https://bugs.php.net/fix.php?id=64005&r=trysnapshottrunk
Fixed in SVN:               https://bugs.php.net/fix.php?id=64005&r=fixed
Fixed in release:           https://bugs.php.net/fix.php?id=64005&r=alreadyfixed
Need backtrace:             https://bugs.php.net/fix.php?id=64005&r=needtrace
Need Reproduce Script:      https://bugs.php.net/fix.php?id=64005&r=needscript
Try newer version:          https://bugs.php.net/fix.php?id=64005&r=oldversion
Not developer issue:        https://bugs.php.net/fix.php?id=64005&r=support
Expected behavior:          https://bugs.php.net/fix.php?id=64005&r=notwrong
Not enough info:            
https://bugs.php.net/fix.php?id=64005&r=notenoughinfo
Submitted twice:            
https://bugs.php.net/fix.php?id=64005&r=submittedtwice
register_globals:           https://bugs.php.net/fix.php?id=64005&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=64005&r=php4
Daylight Savings:           https://bugs.php.net/fix.php?id=64005&r=dst
IIS Stability:              https://bugs.php.net/fix.php?id=64005&r=isapi
Install GNU Sed:            https://bugs.php.net/fix.php?id=64005&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=64005&r=float
No Zend Extensions:         https://bugs.php.net/fix.php?id=64005&r=nozend
MySQL Configuration Error:  https://bugs.php.net/fix.php?id=64005&r=mysqlcfg

Reply via email to