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
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem:
42 - 1 = ?
Subscribe to this entry?

 
 [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-2024 The PHP Group
All rights reserved.
Last updated: Tue Apr 23 19:01:31 2024 UTC