当前位置:网站首页>PHP ksort() function
PHP ksort() function
2022-06-24 05:11:00 【User 1448800】
example
Sort associative arrays in ascending order by key name :
<?php
$age=array("Bill"=>"60","Steve"=>"56","mark"=>"31");
ksort($age);
?>Definition and Usage
ksort() Function sorts an associative array in ascending order by key name .
grammar
ksort(array,sortingtype);
Parameters | describe |
|---|---|
array | It's necessary . Specify the array to sort . |
sortingtype | Optional . Specifies how to arrange the elements of an array / project . Possible value :0 = SORT_REGULAR - Default . Put each item in the regular order (Standard ASCII, Don't change the type ).1 = SORT_NUMERIC - Treat each item as a number .2 = SORT_STRING - Treat each item as a string .3 = SORT_LOCALE_STRING - Treat each item as a string , Based on the current locale ( It can be done by setlocale() Make changes ).4 = SORT_NATURAL - Treat each item as a string , Use similar natsort() Natural ordering .5 = SORT_FLAG_CASE - Can combine ( Press bit or )SORT_STRING or SORT_NATURAL Sort strings , Case insensitive . |
- 0 = SORT_REGULAR - Default . Put each item in the regular order (Standard ASCII, Don't change the type ).
- 1 = SORT_NUMERIC - Treat each item as a number .
- 2 = SORT_STRING - Treat each item as a string .
- 3 = SORT_LOCALE_STRING - Treat each item as a string , Based on the current locale ( It can be done by setlocale() Make changes ).
- 4 = SORT_NATURAL - Treat each item as a string , Use similar natsort() Natural ordering .
- 5 = SORT_FLAG_CASE - Can combine ( Press bit or )SORT_STRING or SORT_NATURAL Sort strings , Case insensitive .
explain
ksort() Function sorts the array by key name , Keep the original key for the array value .
The optional second parameter contains additional sort flags .
If successful , Then return to TRUE, Otherwise return to FALSE.
Technical details
Return value : | Return if successful TRUE, Return if failed FALSE. |
|---|---|
PHP edition : | 4+ |
边栏推荐
- PTA 1046 stroke (15 points)
- Spirit breath development log (9)
- TDP members have made their debut!
- 查找GBase 8c数据库当前索引?
- How to expand virtual machine capacity on vSphere client
- Automatically convert local pictures to network pictures when writing articles
- 让孩子们学习Steam 教育的应用精髓
- Loss and optimization of linear regression, machine learning to predict house prices
- Some excellent plug-ins on Amway vscode
- Spirit breath development log (15)
猜你喜欢

What is the new generation cloud computing architecture cipu of Alibaba cloud?

Hard core observation 553 AI needs to identify almost everyone in the world with hundreds of billions of photos

CTF learning notes 18:iwesec file upload vulnerability-03-content-type filtering bypass

让孩子们学习Steam 教育的应用精髓
![[leetcode daily question] push domino](/img/81/1c31e97d9a245816514bcf47c92107.jpg)
[leetcode daily question] push domino

少儿编程教育在特定场景中的普及作用

解析后人类时代类人机器人的优越性

少儿编程课程改革后的培养方式

Intensive learning and application of "glory of the king" to complete the application of 7 real worlds other than human players

011_ Cascader cascade selector
随机推荐
How novices choose ECs and how to judge the quality of ECS
oracle数据库提示无操作权限的问题
SUSE system cannot install cosfs solution
PHP sort() function
查找GBase 8c数据库当前索引?
Popularization of children's programming education in specific scenarios
Introduction to ebpf
What is the difference between a traditional data center and a cloud computing data center?
What is the secondary domain name of the website? What is the relationship between the secondary domain name and the primary domain name?
解析后人类时代类人机器人的优越性
System design: index
Leetcode (question 2) - adding two numbers
LeetCode 1290. Binary linked list to integer
What is a network domain name? What is the role of a domain name for an enterprise
Black horse programmer machine learning handout: preliminary use of linear regression API
How does the mobile phone remotely connect to the ECS? What should be paid attention to during the operation
CLB health check principle and abnormal troubleshooting
What is the domain name of the website? How much is a domain name
011_ Cascader cascade selector
Tencent cloud audio and video award-winning evaluation | leave online messages or submit evaluation, win Dajiang UAV /iphone/switch and other awards