Buduję niestandardowy menedżer przełącznika do pracy, mój obecny numer jest bardziej estetyczny, ale uważam, że jest to dobre doświadczenie edukacyjne. Pisałem tablicy poniżej dla jasności:PHP podwójna tablica sortowania na podstawie podłańcucha
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
)
Na naszych większych przełączników używam asort($arr);
dostać GigabitEthernet1/1 przyjść przed 2/1, etc ...
Moim celem jest porządek na numer interfejsu (część po "/"), aby 1/8 pojawiła się przed 1/10.
Czy ktoś może wskazać mi właściwy kierunek, chcę pracować dla wyników, ale nie jestem wystarczająco obeznany z PHP, aby wiedzieć, dokąd się udać.
Uwagi: W przypadku większych przełączników wielomodułowych identyfikatory nie są w porządku, więc sortowanie w $ arr [key] nie będzie działać.
To działało idealnie. Teraz, aby zbadać znaczenie. – xandout