note 117777 added to function.sort
| From: | aditycse at gmail dot com | Date: | Fri, 07 Aug 2015 10:34:04 +0000 |
| Subject: | note 117777 added to function.sort | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-203283@lists.php.net to get a copy of this message | ||
/*
* Name : Aditya Mehrotra
* Email: aditycse@gmail.com
*/
//Example for sorting by values for an alphanumeric array also having case-sensitive data
$exampleArray1 = $exampleArray2 = array(
0 => 'example1',
1 => 'Example10',
2 => 'example12',
3 => 'Example2',
4 => 'example3',
5 => 'EXAMPLE10',
6 => 'example10'
);
//default sorting
asort($exampleArray1);
// alphanumeric with case-sensitive data sorting by values
asort($exampleArray2, SORT_STRING | SORT_FLAG_CASE | SORT_NATURAL);
//output of defaut sorting
print_r($exampleArray1);
/*
* output of default sorting
Array
(
[5] => EXAMPLE10
[1] => Example10
[3] => Example2
[0] => example1
[6] => example10
[2] => example12
[4] => example3
)
*/
print_r($exampleArray2);
/*
* output of alphanumeric with case-sensitive data sorting by values
Array
(
[0] => example1
[3] => Example2
[4] => example3
[5] => EXAMPLE10
[1] => Example10
[6] => example10
[2] => example12
)
*/
----
Server IP: 72.52.91.14
Probable Submitter: 115.248.143.4
----
Manual Page -- http://php.net/manual/en/function.sort.php
Edit -- https://master.php.net/note/edit/117777
Del: integrated -- https://master.php.net/note/delete/117777/integrated
Del: useless -- https://master.php.net/note/delete/117777/useless
Del: bad code -- https://master.php.net/note/delete/117777/bad+code
Del: spam -- https://master.php.net/note/delete/117777/spam
Del: non-english -- https://master.php.net/note/delete/117777/non-english
Del: in docs -- https://master.php.net/note/delete/117777/in+docs
Del: other reasons-- https://master.php.net/note/delete/117777
Reject -- https://master.php.net/note/reject/117777
Search -- https://master.php.net/manage/user-notes.php