php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #11372 array_multisort does not maintain key association
Submitted: 2001-06-08 22:09 UTC Modified: 2002-02-26 21:40 UTC
Votes:2
Avg. Score:5.0 ± 0.0
Reproduced:2 of 2 (100.0%)
Same Version:0 (0.0%)
Same OS:0 (0.0%)
From: rkenny at mke dot catalystwms dot com Assigned:
Status: Not a bug Package: Arrays related
PHP Version: 4.0.5 OS: Windows NT 4.0 SP6a
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: rkenny at mke dot catalystwms dot com
New email:
PHP Version: OS:

 

 [2001-06-08 22:09 UTC] rkenny at mke dot catalystwms dot com
Here's a quick script to reproduce the problem:

<?

	$x = array ("filename" => 	  array	(0 => "joe.doc", 1 => "ralph.doc", 2 => "maria.xls")
				, "size" => 	  array	(0 => "jbig", 1 => "rsmall", 2 => "mmed")
				, "modified" =>   array	(0 => "54", 1 => "32", 2 => "99")
				);

#	array_multisort ($x["modified"]);
	asort ($x["modified"]);
	reset ($x["modified"]);
	
	echo "<p><b>Values in x</b><br>";
	while (list ($key, $val) = each ($x)) {
	    echo "$key => $val<br>";
	}
	echo "<p><b>Values in filename</b><br>";
	while (list ($key, $val) = each ($x["filename"])) {
	    echo "$key => $val<br>";
	}
	echo "<p><b>Values in size</b><br>";
	while (list ($key, $val) = each ($x["size"])) {
	    echo "$key => $val<br>";
	}
	echo "<p><b>Values in modified</b><br>";
	while (list ($key, $val) = each ($x["modified"])) {
	    echo "$key => $val<br>";
	}

?>

Uncomment the "array_multisort" line and comment the "asort" line to witness the bug first hand.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2002-02-26 21:40 UTC] yohgaki@php.net
The version of PHP that this bug was reported in is too old. Please
try to reproduce this bug in the latest version of PHP (available
from http://www.php.net/downloads.php

If you are still 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".

I think this is fixed. If not, please reopen.
 
PHP Copyright © 2001-2019 The PHP Group
All rights reserved.
Last updated: Sun Mar 24 19:01:25 2019 UTC