note 33783 modified in function.array-multisort by vrana
| From: | vrana@php.net | Date: | Tue, 17 Aug 2004 13:59:09 +0000 |
| Subject: | note 33783 modified in function.array-multisort by vrana | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-79978@lists.php.net to get a copy of this message | ||
In responce to this:
"It should be noted that both SORT_REGULAR and SORT_STRING appear ot be case sensitive, list
words beginning with capitals first.
It would be nice to have an option which isn't case sensitive.
Allen"
To Make a SORT_STRING ignore case, simply sort without any different cases. By use of the
strtolower() or strtoupper() functions.
The $arrMerch[$iIndex][1] cell contains a string, of course.
<?php
// Create an array that will be sorted, with strtolower() making all the strings lower case.
for ($iIndex = 0; $iIndex < $iAppCount; $iIndex++) {
$arrSort[$iIndex] = strtolower($arrMerch[$iIndex][1]);
}
array_multisort($arrMerch,SORT_ASC,SORT_STRING,$arrSort,
SORT_ASC,SORT_STRING);
?>
There you go.
--was--
In responce to this:
"It should be noted that both SORT_REGULAR and SORT_STRING appear ot be case sensitive, list
words beginning with capitals first.
It would be nice to have an option which isn't case sensitive.
Allen"
To Make a SORT_STRING ignore case, simply sort without any different cases. By use of the
strtolower() or strtoupper() functions.
The $arrMerch[$iIndex][1] cell contains a string, of course.
// Create an array that will be sorted, with strtolower() making all the strings lower case.
for ($iIndex = 0; $iIndex < $iAppCount; $iIndex++) {
$arrSort[$iIndex] = strtolower($arrMerch[$iIndex][1]);
}
array_multisort($arrMerch,SORT_ASC,SORT_STRING,$arrSort,
SORT_ASC,SORT_STRING);
There you go.
http://php.net/manual/en/function.array-multisort.php