当前位置:网站首页>PHP sort() function
PHP sort() function
2022-06-24 05:10:00 【User 1448800】
example
An array $cars The elements in are sorted alphabetically in ascending order :
<?php
$cars=array("Volvo","BMW","Toyota");
sort($cars);
?>Definition and Usage
sort() Function to sort the index array in ascending order .
notes : This function gives a new key name to the unit in the array . The original key name will be deleted .
Return if successful TRUE, Otherwise return to FALSE.
grammar
sort(array,sortingtype);
Parameters | describe |
|---|---|
array | It's necessary . Specify the array to sort . |
sortingtype | Optional . Specifies how to compare 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 .
Technical details
Return value : | Return if successful TRUE, If it fails, return to FALSE. |
|---|---|
PHP edition : | 4+ |
More instances
Example 1
An array $numbers The elements in are sorted in ascending numerical order :
<?php $numbers=array(4,6,2,22,11); sort($numbers); ?>
边栏推荐
- Customer disaster recovery case - a MySQL database migration scheme
- What is the secondary domain name of the website? What is the relationship between the secondary domain name and the primary domain name?
- Digital transformation practice of Zheshang Bank
- NAT
- Zhang Xiaodan, chief architect of Alibaba cloud hybrid cloud: evolution and development of government enterprise hybrid cloud technology architecture
- What domain names do not need to be filed? Is there any process for domain name registration
- Powerbi - for you who are learning
- Weak current engineer, 25g Ethernet and 40g Ethernet: which do you choose?
- How to build a website for ECS? What are the prices of different ECS
- Hard core JS: there may be a memory leak in your program
猜你喜欢

What are the disadvantages of the free IP address replacement tool?

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

Introduction to the "penetration foundation" cobalt strike Foundation_ Cobalt strike linkage msfconsole

Popularization of children's programming education in specific scenarios

Leetcode (question 1) - sum of two numbers

让孩子们学习Steam 教育的应用精髓

Idea creates a servlet and accesses the 404 message

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

Zhang Xiaodan, chief architect of Alibaba cloud hybrid cloud: evolution and development of government enterprise hybrid cloud technology architecture

Training methods after the reform of children's programming course
随机推荐
Analyzing the superiority of humanoid robot in the post human era
Medical industry EDI overview
Detailed explanation of the process after the browser enters the domain name and web address
Redis pipeline technology speed and efficiency increased by 5 times
少儿编程教育在特定场景中的普及作用
[leetcode daily question] push domino
Why domain name should be resolved? What is the domain name registration query
LeetCode 1791. Find the central node of the star chart
Redis installation mode for windows and Linux systems
Bi-sql basic cognition
3 minutes to understand JSON schema
Are you ready for the exam preparation strategy of level II cost engineer in 2022?
Tencent conference rest API x-tc-registered parameter policy update notification
MySQL cases MySQL find out who holds the row lock (RC)
Performance comparison of JS loop traversal methods: for/while/for in/for/map/foreach/every
How to create a virtual machine on vSphere client -- a reliable virtual machine creation tutorial
Powerbi - for you who are learning
Verifying data models in golang
Pgbouncer lightweight PG connection pool management tool
GDB debugging container and command saving