我正在为工作建立一个自定义交换机管理器,我目前的问题更美观,但我认为这是一个很好的学习经验.为了清楚起见,我在下面发布了数组:
Array
(
[1] => FastEthernet0/1
[10] => FastEthernet0/10
[11] => FastEthernet0/11
[12] => FastEthernet0/12
[13] => FastEthernet0/13
[14] => FastEthernet0/14
[15] => FastEthernet0/15
[16] => FastEthernet0/16
[17] => FastEthernet0/17
[18] => FastEthernet0/18
[19] => FastEthernet0/19
[2] => FastEthernet0/2
[20] => FastEthernet0/20
[21] => FastEthernet0/21
[22] => FastEthernet0/22
[23] => FastEthernet0/23
[24] => FastEthernet0/24
[3] => FastEthernet0/3
[4] => FastEthernet0/4
[5] => FastEthernet0/5
[6] => FastEthernet0/6
[7] => FastEthernet0/7
[8] => FastEthernet0/8
[9] => FastEthernet0/9
[25] => Null0
)
Run Code Online (Sandbox Code Playgroud)
在我们更大的交换机上,我使用的asort($arr);是在2/1之前获得GigabitEthernet1/1等等...
我的目标是对接口号进行排序(在'/'之后的部分),以便1/8在1/10之前.
有人能指出我正确的方向,我想为结果工作,但我不熟悉PHP知道到底要去哪里.
注意:在较大的多模块交换机上,ID不是有序的,因此对$ arr [key]的排序将不起作用.
您可以在使用 asort() 时使用该标志,如下所示。
asort($arr, SORT_NATURAL | SORT_FLAG_CASE);print_r($arr);
Run Code Online (Sandbox Code Playgroud)
它将根据您的需要打印/排序数据。
| 归档时间: |
|
| 查看次数: |
639 次 |
| 最近记录: |