#24897 [NEW]: array_multisort() will reindex the array but not if array length is 1
From: chro at sokrates dot uio dot no
Operating system: RH 9.0
PHP version: 5.0.0b1 (beta1)
PHP Bug Type: Arrays related
Bug description: array_multisort() will reindex the array but not if array length is 1
Description:
------------
array_multisort() will reindex the array but not if array length is 1
Produced and reproduced in php.4.3.x and up to 5.beta
Similar (but not the same) as
http://bugs.php.net/bug.php?id=12572
(different function, 12572 is sort() )
Reproduce code:
---------------
<?php
// array_multisort() will reindex the array but not if array length is 1,
is
this a bug?
// array length 1
$a = array(1=>1);
array_multisort($a);
var_dump($a);
// output: array(1) { [1]=> int(1) }
// first index 1, not reindexed!
//----------------------
// array length 2
$a = array(1=>1,2);
array_multisort($a);
var_dump($a);
// output: array(2) { [0]=> int(1) [1]=> int(2) }
// first index 0, reindexed!
?>
Expected result:
----------------
Array should be reindexed to:
output: array(1) { [0]=> int(1) }
on first attempt (where array length = 1)
Actual result:
--------------
output: array(1) { [1]=> int(1) }
array is not reindexed
--
Edit bug report at http://bugs.php.net/?id=24897&edit=1
--
Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=24897&r=trysnapshot4
Try a CVS snapshot (php5): http://bugs.php.net/fix.php?id=24897&r=trysnapshot5
Fixed in CVS: http://bugs.php.net/fix.php?id=24897&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=24897&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=24897&r=needtrace
Try newer version: http://bugs.php.net/fix.php?id=24897&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=24897&r=support
Expected behavior: http://bugs.php.net/fix.php?id=24897&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=24897&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=24897&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=24897&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=24897&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=24897&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=24897&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=24897&r=gnused
Thread (4 messages)
- chro at sokrates dot uio dot no