Krsort (array, type);
Role:
To sort the parameters of an array in descending order
Parameters:
Array: Arrays
Type: optional specifies how the elements/items of the array are arranged. Possible values:
0 = sort_regular-default. Arrange each item in the usual order (standard ASCII, without changing the type).
1 = sort_numeric-Each item is treated as a number.
2 = sort_string-Each item is treated as a string.
3 = sort_locale_string-handles each item as a string, based on the current locale (can be changed by setlocale ()).
4 = sort_natural-handles each item as a string, using a natural sort similar to Natsort ().
5 = sort_flag_case-You can sort strings by combining (bitwise OR) sort_string or sort_natural, not case-sensitive.
return value:
Success returns TRUE, Failure returns false
Example: descending order of key for an array
$a = Array (' 1 ' = ' red ', ' 5 ' = ' Blue ', ' 3 ' = ' 12 '); Krsort ($a); Print_r ($a); Output: Array ([5] = blue [3] = [1] = + red)
Ksort (array, type);
Role:
Sort the key of an array in ascending order
Parameters:
Array: Arrays
Type: Optional. Specifies how to arrange the elements/items of an array. Possible values:
0 = sort_regular-default. Arrange each item in the usual order (standard ASCII, without changing the type).
1 = sort_numeric-Each item is treated as a number.
2 = sort_string-Each item is treated as a string.
3 = sort_locale_string-handles each item as a string, based on the current locale (can be changed by setlocale ()).
4 = sort_natural-handles each item as a string, using a natural sort similar to Natsort ().
5 = sort_flag_case-You can sort strings by combining (bitwise OR) sort_string or sort_natural, not case-sensitive.
return value:
Success returns TRUE, Failure returns false
Example: Sorting an array key in ascending order
$a = Array (' 1 ' = ' red ', ' 5 ' = ' Blue ', ' 3 ' = ' 12 '); Ksort ($a); Print_r ($a); Output: Array ([1] = red [3] = [5] = = blue)
List (var1, var2, var3 ...)
Role:
Assigning an element in an array to a variable in a list
Parameters:
VAR1: Variable Name
VAR2: Variable Name
VAR3: Variable Name
return value:
Returns the array after assignment
Example:
$a = Array (' a ' = = ' red ', ' b ' = ' blue ', ' c ' = ' 12 '); $res = List ($b, $c, $d) = $a; Print_r ($res); Output: Array ([a] = red [b] = blue [C] + 12)
Natcasesort (Array)
Role:
Use natural sort arrays for case-insensitive bleed
Parameters:
Array: Arrays
return value:
Successful return true, failed to Shanghai false
Example:
$a = Array (' a ' = = ' red ', ' b ' = ' blue ', ' c ' = ' purple '); Natcasesort ($a); Print_r ($a); Output: Array ([b] = blue [c] = purple [A] = red)
Natsort (Array)
Role:
Sort an array using natural sort
Parameters:
Array: Arrays
return value:
Successful return true, failed to Shanghai false
Example
$a = Array (' a ' = = ' red ', ' b ' = ' blue ', ' c ' = ' purple '); Natsort ($a); Print_r ($a); Output: Array ([b] = blue [c] = purple [A] = red)
This article from "Snail Crawl" blog, please be sure to keep this source http://10130617.blog.51cto.com/10120617/1896582
PHP Learning Notes-arrays (13)