php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #36502 Windows/Linux inconsistency for array_multisort
Submitted: 2006-02-23 23:03 UTC Modified: 2006-02-24 08:48 UTC
From: kevin at theposseltd dot com Assigned:
Status: Not a bug Package: Arrays related
PHP Version: 4.4.2 OS: Linux
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: kevin at theposseltd dot com
New email:
PHP Version: OS:

 

 [2006-02-23 23:03 UTC] kevin at theposseltd dot com
Description:
------------
My development system is Windows based (XP)PHP 4.4.0 and after uploading the code to my hosting server (LINUX PHP 4.4.2) I get error messages when running the code, which worked fine on Windows. Nobody seems to be able to help me - so I suspect it may be a bug or inconsistency between 4.4.0 and 4.4.2

I am trying to sort a multidimensional array using array_multisort - the coding works perfectly on my development system but not on the Linux host site.

Reproduce code:
---------------
array structure looks like ... (line taken from actual structure)

[17] => Array ( [0] => 98 [event_ID] => 98 [1] => 5 [event_code] => 5 [2] => 0 [event_SIG_code] => 0 [3] => Attraction [event_type] => Attraction [4] => Lookout Discovery Centre [event_name] => Lookout Discovery Centre [5] => Party [event_description] => Party [6] => OmVMYV [event_geocode] => OmVMYV [7] => RG12 7QW [event_postcode] => RG12 7QW [8] => 2005-10-07 [event_start_date] => 2005-10-07 [distance] => Array ( [kilometers] => 43.55 [meters] => 43545.49 [miles] => 27.06 [furlongs] => 216.46 [feet] => 142865.79 [yards] => 47621.93 [inches] => 1714389.5 [nautical] => 23.51 [error] => 0 ) ) 

Code causing the issue ...

foreach ($sort_result as $res) {
	
	$sortAux[] = $res['event_code'];
	array_multisort($sortAux, SORT_ASC,$sort_result);} 

// Re-sorts the GeoCode array by event_code


Expected result:
----------------
Expect the array to be sorted by 'event_code'(as it does in Windows system)

Actual result:
--------------
Actual error output:

Warning: array_multisort(): Array sizes are inconsistent in /content/StartupHostPlus/t/e/tellmewhatson.co.uk/web/event_headline_search.php on line 65


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2006-02-23 23:07 UTC] tony2001@php.net
Thank you for this bug report. To properly diagnose the problem, we
need a short but complete example script to be able to reproduce
this bug ourselves. 

A proper reproducing script starts with <?php and ends with ?>,
is max. 10-20 lines long and does not require any external 
resources such as databases, etc.

If possible, make the script source available online and provide
an URL to it here. Try to avoid embedding huge scripts into the report.


 [2006-02-24 08:48 UTC] tony2001@php.net
Your code is not going to work. Look at the numbers this code outputs:
<?php
$sort_array = Array( Array ('event_id', 11, 'event_type', 'Attraction', 'event_name', 'Discovery Centre'),
                     Array ('event_id', 7, 'event_type', 'Normal', 'event_name', 'Party' ),
                     Array ('event_id', 1, 'event_type', 'Feature','event_name', 'Twyford Zoo' ),
                     Array ('event_id', 12, 'event_type', 'Normal', 'event_name', 'Market Day' ),
                     Array ('event_id', 4, 'event_type','Attraction', 'event_name', 'Bowling Alley' ),
                   );

foreach ($sort_array as $res) {
            $sortAux[] = $res[1];
var_dump(count($sortAux));
var_dump(count($sort_array));
            array_multisort($sortAux, SORT_ASC, $sort_array);
}
?>

Not PHP problem -> bogus.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 19 09:01:27 2024 UTC