Bug #16778 Updated: usort and uasort work only if you give them your array BY REFERENCE.
| From: | sniper@php.net | Date: | Wed, 24 Apr 2002 02:27:48 +0000 |
| Subject: | Bug #16778 Updated: usort and uasort work only if you give them your array BY REFERENCE. | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-5778@lists.php.net to get a copy of this message | ||
ID: 16778
Updated by: sniper@php.net
Reported By: jeremy@titr.uow.edu.au
-Status: Open
+Status: Closed
Bug Type: Arrays related
Operating System: Linux
PHP Version: 4.1.2
New Comment:
Let's close this then.
--Jani
Previous Comments:
------------------------------------------------------------------------
[2002-04-23 22:14:17] jeremy@titr.uow.edu.au
Shame on me ... I don't know how to read the php manual.
In the manual, uasort returns a void ... and NOT the sorted array.
Sorry guys, I was tired yesterday night when I tried for 2 hours to
make this sort working.
I don't think there is a need for a script any more no ?
Thanks Jani
------------------------------------------------------------------------
[2002-04-23 20:24:12] sniper@php.net
And please add a complete, short script which can be used
to reproduce the problem.
--Jani
------------------------------------------------------------------------
[2002-04-23 20:23:35] sniper@php.net
The proto in PHP 4.2.0 for this function is:
bool uasort ( array array, function cmp_function)
Which means, that the fuction only returns TRUE or FALSE
depending whether it succeeded or not.
Please update to PHP 4.2.0 first.
--Jani
------------------------------------------------------------------------
[2002-04-23 20:09:11] jeremy@titr.uow.edu.au
The following code doesn't work :
$received_array = uasort($send_array,"mycmp")
$received_array isn't a correct array (but the integer 1 in general)
Where if I do this :
$received_array = uasort(&$send_array,"mycmp")
$received_array is still not correct, but $send_array has been sorted.
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=16778&edit=1