#27788 [NEW]: array_multisort doesn't mantain index associations with numeric arrays
| From: | mail at spybreak dot de | Date: | Wed, 31 Mar 2004 00:30:58 +0000 |
| Subject: | #27788 [NEW]: array_multisort doesn't mantain index associations with numeric arrays | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-57164@lists.php.net to get a copy of this message | ||
From: mail at spybreak dot de
Operating system: Win2K
PHP version: 4.3.4
PHP Bug Type: Feature/Change Request
Bug description: array_multisort doesn't mantain index associations with numeric arrays
Description:
------------
The manual says that array_multisort mantains key associations. This is
only true if the keys are strings. If the keys are integers on the other
hand, key association is not mantained. I don't think that this is a bug
since it's so obvious. But I wish feedback on this to clear this issue up.
Thanks alot!
Reproduce code:
---------------
<?
//names array. keys are user id's
$names[5] = 'Peter';
$names[7] = 'Jim';
$names[11] = 'Martin';
$names[33] = 'John';
$names[34] = 'Robert';
//age array. keys are user id's
$age[5] = 15;
$age[7] = 19;
$age[11] = 54;
$age[33] = 29;
$age[34] = 17;
//sort names array by ages
array_multisort($age, $names);
var_dump($names);
?>
Expected result:
----------------
I expect this:
// _should_ return
//
// array
// 5 => 'Peter'
// 34 => 'Robert'
// 7 => 'Jim'
// 33 => 'John'
// 11 => 'Martin'
Actual result:
--------------
// returns the following for me
//
// array
// 0 => 'Peter'
// 1 => 'Robert'
// 2 => 'Jim'
// 3 => 'John'
// 4 => 'Martin'
--
Edit bug report at http://bugs.php.net/?id=27788&edit=1
--
Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=27788&r=trysnapshot4
Try a CVS snapshot (php5): http://bugs.php.net/fix.php?id=27788&r=trysnapshot5
Fixed in CVS: http://bugs.php.net/fix.php?id=27788&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=27788&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=27788&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=27788&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=27788&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=27788&r=support
Expected behavior: http://bugs.php.net/fix.php?id=27788&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=27788&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=27788&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=27788&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=27788&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=27788&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=27788&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=27788&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=27788&r=float