#27788 [Opn]: array_multisort doesn't mantain index associations with numeric arrays
| From: | derick@php.net | Date: | Wed, 31 Mar 2004 07:08:59 +0000 |
| Subject: | #27788 [Opn]: array_multisort doesn't mantain index associations with numeric arrays | ||
| References: | 1 | Groups: | php.doc |
| Request: | Send a blank email to phpdoc+get-969359849@lists.php.net to get a copy of this message | ||
ID: 27788
Updated by: derick@php.net
Reported By: mail at spybreak dot de
Status: Open
-Bug Type: Feature/Change Request
+Bug Type: Documentation problem
Operating System: Win2K
PHP Version: 4.3.4
Assigned To: andrei
New Comment:
Making this a documentation problem, as it is the correct behavior.
Previous Comments:
------------------------------------------------------------------------
[2004-03-30 19:30:58] mail at spybreak dot de
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 this bug report at http://bugs.php.net/?id=27788&edit=1