note 75787 deleted from ref.array by levim

From: Date: Tue, 06 May 2014 22:00:00 +0000
Subject: note 75787 deleted from ref.array by levim
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-199435@lists.php.net to get a copy of this message
Note Submitter: peanutpad at msn dot com ---- heres a function from http://www.linksback.org Feedback welcome, of course! Public domain, yadda yadda. function mySort(&$array,$key) { if (!is_array($array) || count($array) == 0) return true; $assocSortCompare = '$a = $a["'.$key.'"]; $b = $b["'.$key.'"];'; if (is_numeric($array[0][$key])) { $assocSortCompare.= ' return ($a == $b) ? 0 : (($a < $b) ? -1 : 1);'; } else { $assocSortCompare.= ' return strcmp($a,$b);'; } $assocSortCompare = create_function('$a,$b',$assocSortCompare); return usort($array,$assocSortCompare); }

« previous php.notes (#199435) next »