#33763 [NEW]: array_multisort() affects copy of an array in function
| From: | marceloburegio at gmail dot com | Date: | Tue, 19 Jul 2005 04:28:29 +0000 |
| Subject: | #33763 [NEW]: array_multisort() affects copy of an array in function | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-82115@lists.php.net to get a copy of this message | ||
From: marceloburegio at gmail dot com
Operating system: Fedora Core 4 and Windows 2000
PHP version: 5.0.4
PHP Bug Type: Arrays related
Bug description: array_multisort() affects copy of an array in function
Description:
------------
Using array_multisort() in a function with copy of local array, this
affects the original array.
It's same to bug #32031
I solve this changing the code:
$arrSort = $arr;
to:
$arrSort = $arr + array();
Reproduce code:
---------------
function bug_array($arr) {
$arrSort = $arr;
array_multisort($arrSort);
}
$arr = array(1, 0);
print_r($arr);
bug_array($arr);
print_r($arr);
Expected result:
----------------
Array
(
[0] => 1
[1] => 0
)
Array
(
[0] => 1
[1] => 0
)
Actual result:
--------------
Array
(
[0] => 1
[1] => 0
)
Array
(
[0] => 0
[1] => 1
)
--
Edit bug report at http://bugs.php.net/?id=33763&edit=1
--
Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=33763&r=trysnapshot4
Try a CVS snapshot (php5.0): http://bugs.php.net/fix.php?id=33763&r=trysnapshot50
Try a CVS snapshot (php5.1): http://bugs.php.net/fix.php?id=33763&r=trysnapshot51
Fixed in CVS: http://bugs.php.net/fix.php?id=33763&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=33763&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=33763&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=33763&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=33763&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=33763&r=support
Expected behavior: http://bugs.php.net/fix.php?id=33763&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=33763&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=33763&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=33763&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=33763&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=33763&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=33763&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=33763&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=33763&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=33763&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=33763&r=mysqlcfg