二维数组的‘分组’排序
$val){ asort($new[$key]);//分别对每一组的数据进行排序; $tmp=$new[$key];//将排序后的数据赋值给一个临时数组; $tmp[]=$key;//将原来数组的键值加入到临时数组的末尾,为后期的修改键值的步骤做准备; $tmp2=$new[$key]; $a=array_shift($tmp2)*100;//将每一组的第一项(最小项)数据取出来,以aa组为例子,$a此时的值就为33; if(array_key_exists($a,$aa)){++$q_count;$a=$a+$q_count;} $aa[$a]=$tmp;//新建一个数组,以$aa(比如33)为键值; ksort($aa);//按照键值排序 } foreach($aa as $key=>$val){//按照键值排序的数组,已经失去了原来的键值,比如aa/bb/cc/dd之类的,好在我们之前已经将键值存入了临时数组的末尾; $b=array_pop($aa[$key]);//将键值取出来; $bb[$b]=$aa[$key];//从新建立一个数组,使用之前的键值(aa/bb/cc) } return $bb;//返回 } $c=arr_group_sort($new); print_r($new);//原数组; print_r($c);//分组排序后的数组; ?>
Copy after login
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article
Roblox: Grow A Garden - Complete Mutation Guide
3 weeks ago
By DDD
Roblox: Bubble Gum Simulator Infinity - How To Get And Use Royal Keys
3 weeks ago
By 尊渡假赌尊渡假赌尊渡假赌
How to fix KB5055612 fails to install in Windows 10?
3 weeks ago
By DDD
Nordhold: Fusion System, Explained
3 weeks ago
By 尊渡假赌尊渡假赌尊渡假赌
Mandragora: Whispers Of The Witch Tree - How To Unlock The Grappling Hook
3 weeks ago
By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics
Java Tutorial
1665
14


CakePHP Tutorial
1423
52


Laravel Tutorial
1321
25


PHP Tutorial
1269
29


C# Tutorial
1249
24

