当前位置:网站首页>PHP multidimensional array sorting
PHP multidimensional array sorting
2022-06-30 14:09:00 【Zhen Jie.】
array_column() and array_multisort() Use it with
<?php
$data = array(
array(
'id' => 5698,
'first_name' => 'Bill',
'add_time' => 1234,
),
array(
'id' => 4767,
'first_name' => 'Steve',
'add_time' => 1233,
),
array(
'id' => 3809,
'first_name' => 'Mark',
'add_time' => 1239,
)
);
// According to the fields add_time An array $data In ascending order
$add_time = array_column($data,'add_time');
array_multisort($add_time,SORT_ASC,$data);
var_dump($data);
?>
Output results :
array(3) {
[0]=>
array(3) {
["id"]=>
int(4767)
["first_name"]=>
string(5) "Steve"
["last_time"]=>
int(1233)
}
[1]=>
array(3) {
["id"]=>
int(5698)
["first_name"]=>
string(4) "Bill"
["last_time"]=>
int(1234)
}
[2]=>
array(3) {
["id"]=>
int(3809)
["first_name"]=>
string(4) "Mark"
["last_time"]=>
int(1239)
}
}
边栏推荐
- What network security problems are exposed when a large-scale QQ number theft event occurs?
- 【刷题篇】爱吃香蕉的珂珂
- Cost forecast of PMP (BAC, EAC, etc)
- Getting started with shell Basics
- Race of golang
- Observable, reliable: the first shot of cloudops series Salon of cloud automation operation and maintenance
- Unity animator parameter
- Introduction to the renewal of substrate source code: the pallet alliance is incorporated into the main line,
- MFQE 2.0: A New Approach for Multi-FrameQuality Enhancement on Compressed Video
- Pit used by go language array type
猜你喜欢

Mysql database foundation: stored procedures and functions

损失函数:DIOU loss手写实现

More than 20 years after Hong Kong's return, Tupu digital twin Hong Kong Zhuhai Macao Bridge has shocked

Multi terminal collaboration of Huawei accounts to create a better internet life

Observable, seulement fiable: première bombe de salon de la série cloudops d'exploitation et d'entretien automatisés dans le nuage

Observable, reliable: the first shot of cloudops series Salon of cloud automation operation and maintenance

可觀測,才可靠:雲上自動化運維CloudOps系列沙龍 第一彈

【观察】智能产业加速,为何AI算力要先行?

This article explains the concepts of typed array, arraybuffer, typedarray, DataView, etc

Wuenda 2022 machine learning special course evaluation is coming!
随机推荐
【刷题篇】爱吃香蕉的珂珂
get请求与post提交区别的简易理解
Jetpack Compose 实现完美屏幕适配
[scientific research data processing] [practice] frequency analysis chart of category variables, distribution chart of numerical variables and normality test (including lognormal)
Three uses of golang underscores
Google Earth engine (GEE) -- converts string to number and applies it to time search (ee.date.fromymd)
Why can't the database table be written into data
步骤详解 | 助您轻松提交 Google Play 数据安全表单
Apache Doris comparison optimization Encyclopedia
【Redis 系列】redis 学习十六,redis 字典(map) 及其核心编码结构
【观察】智能产业加速,为何AI算力要先行?
Go common lock mutex and rwmutex
[the path of system analyst] Chapter 5 Software Engineering (Agile Development)
In the digital age, XDR (extended detection and response) has unlimited possibilities
This editor will open source soon!
Click the TD cell of table to open the dialog pop-up window. After obtaining the value, put the value back into the TD cell
Getting started with shell Basics
“即服务”,企业数字化转型的必然选择
mysql拒绝访问、管理员身份打开的
Google Earth Engine(GEE)——GHSL:全球人类住区层,建成网格 1975-1990-2000-2015 (P2016) 数据集