php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #36633 array_multisort : Array sizes are inconsistent
Submitted: 2006-03-06 19:00 UTC Modified: 2006-03-06 19:06 UTC
From: trucall at gmail dot com Assigned:
Status: Not a bug Package: Arrays related
PHP Version: 5.1.2 OS: linux 2.6.12-10-686
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: trucall at gmail dot com
New email:
PHP Version: OS:

 

 [2006-03-06 19:00 UTC] trucall at gmail dot com
Description:
------------
I'm not sure is a bug but I don't understand why the first block is executed correctly whereas the second one (same code) returns with this warning:

Warning: array_multisort() [function.array-multisort]: Array sizes are inconsistent in /usr/local/httpd-2.2.0/htdocs/test/multisort.php on line 27

Reproduce code:
---------------
<?
error_reporting(E_ALL);

// first block 
$data = array();

$data[2] = array('volume' => 67, 'edition' => 2);
$data[3] = array('volume' => 86, 'edition' => 1);

foreach ($data as $key => $row) {
   $volume[$key]  = $row['volume'];
   $edition[$key] = $row['edition'];
}

array_multisort($volume, SORT_DESC, $edition, SORT_ASC, $data);

// second block (equal to first block)
$data = array();

$data[2] = array('volume' => 67, 'edition' => 2);
$data[3] = array('volume' => 86, 'edition' => 1);

foreach ($data as $key => $row) {
   $volume[$key]  = $row['volume'];
   $edition[$key] = $row['edition'];
}

array_multisort($volume, SORT_DESC, $edition, SORT_ASC, $data);

?>

Expected result:
----------------
Both blocks give the same result.




Actual result:
--------------
Warning: array_multisort() [function.array-multisort]: Array sizes are inconsistent in /usr/local/httpd-2.2.0/htdocs/test/multisort.php on line 27

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2006-03-06 19:06 UTC] tony2001@php.net
They _are_ inconsistent: add var_dump($volume); before the second array_multisort() and you'll see it.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Mon Jun 30 07:02:47 2025 UTC