#43091 [Opn->Bgs]: array_multisort has no effect on static variables
| From: | tony2001@php.net | Date: | Mon, 12 Nov 2007 10:14:05 +0000 |
| Subject: | #43091 [Opn->Bgs]: array_multisort has no effect on static variables | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-119513@lists.php.net to get a copy of this message | ||
ID: 43091
Updated by: tony2001@php.net
Reported By: darrenoh at sidepotsinternational dot com
-Status: Open
+Status: Bogus
Bug Type: Arrays related
Operating System: OS X
PHP Version: 4.4.7
New Comment:
Thank you for taking the time to report a problem with PHP.
Unfortunately you are not using a current version of PHP --
the problem might already be fixed. Please download a new
PHP version from http://www.php.net/downloads.php
If you are able to reproduce the bug with one of the latest
versions of PHP, please change the PHP version on this bug report
to the version you tested and change the status back to "Open".
Again, thank you for your continued support of PHP.
Previous Comments:
------------------------------------------------------------------------
[2007-10-23 22:40:31] darrenoh at sidepotsinternational dot com
Description:
------------
array_multisort() will not sort static variables.
Reproduce code:
---------------
function sort_test() {
static $data = NULL;
if (!isset($data)) {
$data[] = array('volume' => 67, 'edition' => 2);
$data[] = array('volume' => 86, 'edition' => 1);
$data[] = array('volume' => 85, 'edition' => 6);
$data[] = array('volume' => 98, 'edition' => 2);
$data[] = array('volume' => 86, 'edition' => 6);
$data[] = array('volume' => 67, 'edition' => 7);
foreach ($data as $key => $row) {
$volume[$key] = $row['volume'];
$edition[$key] = $row['edition'];
}
array_multisort($volume, SORT_DESC, $edition, SORT_ASC, $data);
}
return $data;
}
Expected result:
----------------
array(
0 => array('volume' => 98, 'edition' => 2),
1 => array('volume' => 86, 'edition' => 1),
2 => array('volume' => 86, 'edition' => 6),
3 => array('volume' => 85, 'edition' => 6),
4 => array('volume' => 67, 'edition' => 7),
5 => array('volume' => 67, 'edition' => 2),
)
Actual result:
--------------
array(
0 => array('volume' => 67, 'edition' => 2),
1 => array('volume' => 86, 'edition' => 1),
2 => array('volume' => 85, 'edition' => 6),
3 => array('volume' => 98, 'edition' => 2),
4 => array('volume' => 86, 'edition' => 6),
5 => array('volume' => 67, 'edition' => 7),
)
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=43091&edit=1