note 66219 added to function.usort
| From: | Numbertype??? at osu1 dot php dot net | Date: | Wed, 17 May 2006 01:13:35 +0000 |
| Subject: | note 66219 added to function.usort | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-111470@lists.php.net to get a copy of this message | ||
function arfsort($a,$fl){
$GLOBALS['__ARFSORT_LIST__'] = $fl;
usort($a,'arfsort_func');
return $a;
}
function arfsort_func($a,$b) {
foreach ($GLOBALS['__ARFSORT_LIST__'] as $f) {
switch ($f[1]) { // switch on ascending or descending value
case "d":
## Add number type sort
if (is_numeric($a[$f[0]])) {
if ($b[$f[0]] < $a[$f[0]]) $strc = -1;
else if ($b[$f[0]] > $a[$f[0]]) $strc = 1;
else $strc = 0;
} else {
$strc = strcmp($b[$f[0]],$a[$f[0]]);
}
if ( $strc != 0 ){
return $strc;
}
break;
default:
if (is_numeric($a[$f[0]])) {
if ($b[$f[0]] > $a[$f[0]]) $strc = -1;
else if ($b[$f[0]] < $a[$f[0]]) $strc = 1;
else $strc = 0;
} else {
$strc = strcmp($a[$f[0]],$b[$f[0]]);
}
if ($strc != 0){
return $strc;
}
break;
}
}
return 0;
}
----
Server IP: 211.43.210.124
Probable Submitter: 168.249.214.181
----
X-Spam-Status: No, hits=3.1 required=5.0 tests=DATE_MISSING,FROM_NO_LOWER
autolearn=no version=2.64
----
Manual Page -- http://www.php.net/manual/en/function.usort.php
Edit -- http://master.php.net/note/edit/66219
Del: integrated -- http://master.php.net/note/delete/66219/integrated
Del: useless -- http://master.php.net/note/delete/66219/useless
Del: bad code -- http://master.php.net/note/delete/66219/bad+code
Del: spam -- http://master.php.net/note/delete/66219/spam
Del: non-english -- http://master.php.net/note/delete/66219/non-english
Del: in docs -- http://master.php.net/note/delete/66219/in+docs
Del: other reasons-- http://master.php.net/note/delete/66219
Reject -- http://master.php.net/note/reject/66219
Search -- http://master.php.net/manage/user-notes.php