Edit report at http://bugs.php.net/bug.php?id=54968&edit=1
ID: 54968 Updated by: [email protected] Reported by: jens at freude-now dot de Summary: arsort -Status: Open +Status: Bogus Type: Feature/Change Request Package: Arrays related Operating System: OS X 10.6 PHP Version: 5.3.6 Block user comment: N Private report: N New Comment: Sorting 0 elements is not a failure case. It is perfectly valid for an array to have no elements and for this case to not cause a problem in the code. Otherwise you would always have to check the number of elements in the array before trying to sort it if you want to avoid errors. Previous Comments: ------------------------------------------------------------------------ [2011-06-01 09:24:17] jens at freude-now dot de Description: ------------ --- >From manual page: http://www.php.net/function.arsort#Rückgabewerte --- I expected if I want to sort an empty array that the functions gives back a false because there is nothing to sort. But the functions gives back a true. Test script: --------------- $t = array(); echo '<pre>count($t) ::'; print_r( count($t)); echo '</pre>'; if(arsort($t)) { echo '<pre>$t ::'; print_r( $t); echo '</pre>'; } Expected result: ---------------- false Actual result: -------------- true ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/bug.php?id=54968&edit=1
