The collator_asort() function is an inbuilt function in PHP which is used to sort array maintaining the index association. This function sorts an array such that array indices maintain their correlation with the array elements they are associated with. Thee array elements are sorted according to current locale rules.
- Procedural style:
bool collator_asort( $coll, &$arr, $sort_flag )
- Object oriented style:
public bool Collator::asort( &$arr, $sort_flag )
Parameters: This function accepts three parameters as mentioned above and described below:
- $coll: This parameter is used as collator object.
- $arr: This parameter contains the array of strings which need to sort.
- $sort_flag: It is optional parameter which is used to define the sorting method, one of the following:
- Collator::SORT_REGULAR: It compare items normally. It is the default sorting.
- Collator::SORT_NUMERIC: It compare items numerically.
- Collator::SORT_STRING: It compare items as strings.
Return Value: This function returns True on success or False on failure.
Below programs illustrate the collator_asort() function in PHP:
array ( 'C' => '9', 'A' => '30', 'B' => '48', 'D' => '60', )
array ( 'A' => '30', 'B' => '48', 'D' => '60', 'C' => '9', )
- How to get the function name inside a function in PHP ?
- D3.js | d3.lab() Function
- PHP | exp() Function
- PHP | Ds\Map put() Function
- D3.js | d3.hcl() Function
- PHP | sin( ) Function
- PHP | abs() Function
- PHP | cos( ) Function
- PHP | tan( ) Function
- D3.js | d3.map.set() Function
- PHP | next() Function
- PHP | Ds\Map get() Function
- D3.js | d3.sum() function
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.