note 28068 deleted from function.usort by cmb

From: Date: Sun, 25 Nov 2018 11:35:37 +0000
Subject: note 28068 deleted from function.usort by cmb
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-209767@lists.php.net to get a copy of this message
Note Submitter: steveNO_SPAM at AXE_MEcontentwatch dot com ---- 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: <?php 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 ) { // ... // } } ?>

« previous php.notes (#209767) next »