This article mainly introduces how php sorts associated arrays by values through asort (). The example analyzes the functions and usage skills of the asort () function in php, for more information, see the following example. php uses asort () to
Asort () Definition and usage
The Asort () function sorts the array and maintains the index relationship. It is primarily used to sort the associative arrays that are important for the cell order.
The Second optional parameter contains an additional
First, the concept:1, natural sorting method: that is, according to the natural number of the size of the order, such as "10>2";2, the computer standard sorting method: is to compare by character, sort, for example "2>10" (because the first bit 2>1);
The asort () function sorts arrays and maintains the index relationship. It is mainly used to sort the arrays that are very important to the unit order. The second optional parameter contains an additional sorting identifier. If the call succeeds,
The asort () function sorts arrays and maintains the index relationship. It is mainly used to sort the arrays that are very important to the unit order. The second optional parameter contains an additional sorting identifier. If the call succeeds,
There are very handy ways to reorder arrays in PHP--asort, the use of Asort can be seen here. However, when sorting an array containing Chinese keys, asort is sometimes not in alphabetical order. This is mainly a coding problem, if the encoding for
PHP function asort () is parsed by sorting values. We mentioned in the previous article how to use the ksort () function to sort by keywords. So today we will focus on how to use values to sort arrays. We mentioned in the previous article how to use
Asort () Definition and usageThe Asort () function sorts the array and maintains an indexed relationship. It is primarily used to sort the associative arrays that are important to the order of the cells.
The optional second parameter contains an
This paper illustrates the use of sort, asort and ksort in the sequence of PHP arrays for reference. The specific examples are as follows:
01
02
$arr = Array (' d ' => ' SDF ', ' R ' => ' SDF ', ' a ' => '
In our previous article, we mentioned how to use the Ksort () function to sort by keyword. So, today we'll focus on how to use the value array to sort. In this process, we will useThe specific code for Listing E is as follows:
Asort () Definition and usageThe asort () function sorts arrays and maintains the index relationship. It is mainly used to sort the arrays that are very important to the unit order.
The second optional parameter contains an additional sorting
Ascending: Descending from low to High: from high to lowsort ()sorting an array in ascending order by value will delete the original key name and re-assign the new nameRsort ()the array is descending by valueSort, will beDelete the original key
Common array functions in php (8) sorting functions (sort, rsort, usort, asort, uasort, arsort, ksort, uksort, krsort, natsort, natcasesort, array_multisort), natcasesort
Test environment: php5.3.29
sort_flagsYou can use the following values
sort--to sort the Val of an arrayksort--to sort the key values of an arrayasort--the array, the corresponding relationship between the key and the value is unchanged1. Sort arrayThe format is as follows: bool Sort (array & $array [, int $sort _flags]
The example in this article describes how PHP uses Asort () to sort associative arrays by value. Share to everyone for your reference. The specific analysis is as follows:
PHP uses Asort () to sort the associative array by value, and the difference
This paper illustrates the use of sort, asort and ksort in the sequence of PHP arrays for reference. The specific examples are as follows:
' SDF ', ' R ' => ' SDF ', ' a ' => ' eee ');
Sort ($arr); The value of the array is//asort, the
The reverse of the PHP array in an article, "How to sort php arrays," we introduced the sort, asort, and Ksort, which are sorted in ascending order of the array, so if you want to implement the reverse of the arrays? Here's another set of functions
In an article "How to sort PHP arrays" in reverse order, we introduced sort, asort, and ksort, which sort arrays in ascending order, so what if we want to implement the inverted order of the array? The following is another group of functions we want
Array: creates a new array. Array_walk: allows a user-defined function to process every element in the array. Arsort: sorts the array values from large to small. Asort: sorts the array values from small to large. Count: calculates the elements in a
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.