note 28068 added to function.usort
| From: | steveNO_SPAM at AXE_MEcontentwatch dot com | Date: | Tue, 31 Dec 2002 20:11:43 +0000 |
| Subject: | note 28068 added to function.usort | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-41523@lists.php.net to get a copy of this message | ||
The sort functions do nothing if identical keys exist. Of course, you shouldn't have identical
keys anyway, but this just might save someone else the oodles of time it took me to figure out while
using multi-dimentional arrays:
class myArticleList {
// ... //
function &getList () {
// works
$a = array (
"articleList1" => array ( "2", "3" ),
"articleList2" => array ( "3" , "4")
);
usort( $a, array( $this, "compareByTitle") );
// doesn't work
$b = array (
"articleList" => array ( "2", "3" ),
"articleList" => array ( "3" , "4")
);
usort( $b, array( $this, "compareByTitle") );
}
function compareByTitle( $a, $b ) {
// ... //
}
}
--
http://www.php.net/manual/en/function.usort.php
http://master.php.net/manage/user-notes.php?action=edit+28068
http://master.php.net/manage/user-notes.php?action=delete+28068
http://master.php.net/manage/user-notes.php?action=reject+28068