php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #16778 usort and uasort work only if you give them your array BY REFERENCE.
Submitted: 2002-04-23 20:09 UTC Modified: 2002-04-23 22:27 UTC
From: jeremy at titr dot uow dot edu dot au Assigned:
Status: Closed Package: Arrays related
PHP Version: 4.1.2 OS: Linux
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: jeremy at titr dot uow dot edu dot au
New email:
PHP Version: OS:

 

 [2002-04-23 20:09 UTC] jeremy at titr dot uow dot edu dot 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.

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2002-04-23 20:23 UTC] 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:24 UTC] sniper@php.net
And please add a complete, short script which can be used
to reproduce the problem.

--Jani



 [2002-04-23 22:14 UTC] jeremy at titr dot uow dot edu dot 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 22:27 UTC] sniper@php.net
Let's close this then.

--Jani

 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Wed Sep 11 17:02:22 2024 UTC