Bug #54980 [NEW]: array_multisort uses second array to sort
From:
Operating system: Irrelevant
PHP version: Irrelevant
Package: Arrays related
Bug Type: Bug
Bug description:array_multisort uses second array to sort
Description:
------------
I thought array_multisort sorts the first array and orders the consequent
arrays
accordingly. Changing $sort['C'] to 3 indeed makes the error message go
away so we think
the error is only triggered if the sort does not happen in the first array.
This is
related to http://bugs.php.net/bug.php?id=54259
but I have simplified
Brad's script as
much as I can -- and he reported as a feature request. I think this is a
bug. At least a
documentation bug.
Test script:
---------------
$sort['A'] = 2;
$sort['B'] = 1;
$sort['C'] = 1;
$menu['A'] = 0;
$menu['B'] = (object) array(0);
$menu['C'] = 0;
array_multisort($sort, SORT_NUMERIC, $menu);
Expected result:
----------------
No error message shown
Actual result:
--------------
PHP Notice: Object of class stdClass could not be converted to int in
/tmp/chx_array_multisort.txt on line 11
--
Edit bug report at http://bugs.php.net/bug.php?id=54980&edit=1
--
Try a snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=54980&r=trysnapshot52
Try a snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=54980&r=trysnapshot53
Try a snapshot (trunk): http://bugs.php.net/fix.php?id=54980&r=trysnapshottrunk
Fixed in SVN: http://bugs.php.net/fix.php?id=54980&r=fixed
Fixed in SVN and need be documented: http://bugs.php.net/fix.php?id=54980&r=needdocs
Fixed in release: http://bugs.php.net/fix.php?id=54980&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=54980&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=54980&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=54980&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=54980&r=support
Expected behavior: http://bugs.php.net/fix.php?id=54980&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=54980&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=54980&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=54980&r=globals
PHP 4 support discontinued: http://bugs.php.net/fix.php?id=54980&r=php4
Daylight Savings: http://bugs.php.net/fix.php?id=54980&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=54980&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=54980&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=54980&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=54980&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=54980&r=mysqlcfg
Thread (2 messages)
- chx1975 at gmail dot com