Edit report at http://bugs.php.net/bug.php?id=54968&edit=1

 ID:                 54968
 User updated by:    jens at freude-now dot de
 Reported by:        jens at freude-now dot de
 Summary:            arsort
 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:

mmh, imagine we, you and me, want to sort the coins in our pocket. But
we don't have any coins. Can you sort it? I can't.


Previous Comments:
------------------------------------------------------------------------
[2011-06-01 09:53:23] ras...@php.net

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.

------------------------------------------------------------------------
[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

Reply via email to