|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2000-08-25 09:32 UTC] ccjeagle at ms6 dot hinet dot net
Seems that array_multisort() flags should be bit-or-ed, not seperated by comma.
i.e. array_multisort($arr1,SORT_DESC|SORT_NUMERIC,
$arr2,SORT_ASC|SORT_STRING),
NOT array_multisort($arr1,SORT_DESC,SORT_NUMERIC,
$arr2, SORT_ASC,SORT_STRING)
As document said.
<?php
$array1 = array(1,7,5,5,5) ;
$array2 = array(9,7,6,'b','a') ;
array_multisort($array1,SORT_DESC,SORT_REGULAR,
$array2,SORT_NUMERIC,SORT_DESC) ;
// Got a warning that parameter 3 should be an array
array_multisort($array1,SORT_DESC|SORT_REGULAR,
$array2,SORT_NUMERIC|SORT_DESC) ;
// That's OK
?>
I think the proto should be :
bool array_multisort (array ar1 [, mixed arg ] [, array ...])
Regards,
CCJ
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2026 The PHP GroupAll rights reserved. |
Last updated: Mon Jun 15 22:00:02 2026 UTC |
In pl2 this is correct only array_multisort($array1,SORT_DESC|SORT_REGULAR, $array2,SORT_NUMERIC|SORT_DESC) ; works. In 4.0.2 onwards both of these appear to work. array_multisort($array1,SORT_DESC,SORT_REGULAR, $array2,SORT_NUMERIC,SORT_DESC) ; array_multisort($array1,SORT_DESC|SORT_REGULAR, $array2,SORT_NUMERIC|SORT_DESC) ; Do you guys think we should add a note to the manual about this behaviour?