php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #52733
Submitted: 2010-08-30 02:50 UTC Modified: 2010-08-30 03:02 UTC
From: phpstars at gmail dot com Assigned:
Status: Not a bug Package: Output Control
PHP Version: 5.3.3 OS: Windows 7
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: phpstars at gmail dot com
New email:
PHP Version: OS:

 

 [2010-08-30 02:50 UTC] phpstars at gmail dot com
Description:
------------
I found this problem , use the latest version of XAMPP

<?PHP
$array1 = array (4,3,1,5,2);
$array2 = array (7,9,6,10,8);
array_multisort($array1,$array2);
print_r ($array1); // Result : Array ( [0] => 1 [1] => 2 [2] => 3 [3] => 4 [4] => 5 ) 
echo '<BR>';
print_r ($array2); // Result : Array ( [0] => 6 [1] => 8 [2] => 9 [3] => 7 [4] => 10 ) 

// Note : Number 7 in the $array2 sorted after number 9

echo '<BR><HR><BR>';
$array1 = array (4,3,1,5,2);
$array2 = array (7,9,6,10,8);
array_multisort($array1);
array_multisort($array2);
print_r ($array1); // Result : Array ( [0] => 1 [1] => 2 [2] => 3 [3] => 4 [4] => 5 ) 
echo '<BR>';
print_r ($array2); // Result : Array ( [0] => 6 [1] => 7 [2] => 8 [3] => 9 [4] => 10 ) 

// Note : But when array_multisort($array2); separately was used, the output was correct
?>

Test script:
---------------
 

Expected result:
----------------
 

Actual result:
--------------
 

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2010-08-30 03:02 UTC] rasmus@php.net
-Status: Open +Status: Bogus
 [2010-08-30 03:02 UTC] rasmus@php.net
That's not a bug.  You are confused about how array_multisort() works.  Read the 
documentation again and look at the examples.  The output you are getting is the 
expected output.  The second array is put in the same order as the first.
 [2010-08-30 06:56 UTC] phpstars at gmail dot com
So the correct code:

$array1 = array (2,3,1,5,4);
$array2 = array (7,8,6,10,9);
array_multisort($array1,$array2);


Thanks for your attention
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Dec 26 13:01:30 2024 UTC