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
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:
21 - 20 = ?
Subscribe to this entry?

 
 [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

Add a Patch

Pull Requests

Add a Pull Request

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 Mar 28 12:01:27 2024 UTC