我有unix磁盤輸出,我想要轉換成每行相關數組,因此用戶可以選擇可用磁盤用於下一個vg創建。PHP陣列的字符串分列到關聯數組
當前數組項的輸出。每列之間只有一個空白區域,我只是做了一些標籤,因此它更易於閱讀。
array(11) {
[0]=> string(141) "vg1 LVM 136G /dev/cciss/c0d0p2 N/A N/A LOCAL N/A N/A NO "
[1]=> string(141) "vg2 LVM 1G /dev/mapper/mpath28p1 60060e80166fa70000016fa700000013 /dev/dm-33 R700 LS1000 0013 YES "
[2]=> string(141) "vg3 LVM 60G /dev/mapper/mpath27p1 60060e80166fa70000016fa700000012 /dev/dm-34 R700 LS1000 0012 YES "
[3]=> string(141) "vg4 LVM 60G /dev/mapper/mpath29p1 60060e80166fa70000016fa700000014 /dev/dm-35 R700 LS1000 0014 NO "
[4]=> string(141) "***AVAILABLE*** FREE 2G /dev/mapper/mpath21p1 60060e80167220000001722000000048 /dev/dm-37 R700 LS2000 0048 YES "
[5]=> string(141) "***AVAILABLE*** FREE 2G /dev/mapper/mpath22p1 60060e80167220000001722000000049 /dev/dm-36 R700 LS2000 0049 YES "
[6]=> string(141) "***AVAILABLE*** FREE 90G /dev/mapper/mpath23p1 60060e80166fa70000016fa70000000e /dev/dm-31 R700 LS1000 000e YES "
[7]=> string(141) "***AVAILABLE*** FREE 90G /dev/mapper/mpath24p1 60060e80166fa70000016fa70000000f /dev/dm-39 R700 LS1000 000f YES "
[8]=> string(141) "***AVAILABLE*** FREE 90G /dev/mapper/mpath25p1 60060e80166fa70000016fa700000010 /dev/dm-30 R700 LS1000 0010 YES "
[9]=> string(141) "***AVAILABLE*** FREE 90G /dev/mapper/mpath26p1 60060e80166fa70000016fa700000011 /dev/dm-32 R700 LS1000 0011 YES "
[10]=> string(141) "***AVAILABLE*** FREE 2G /dev/mapper/mpath30p1 60060e80167220000001722000000047 /dev/dm-38 R700 LS2000 0047 YES "
我想這樣做結束了這樣的事情。我一直在嘗試不同的foreach循環,但還沒有得到它的工作。任何幫助/建議表示讚賞。
[0] => name=>vg1 type=>LVM lun_size=>136G mpath_name=>/dev/cciss/c0d0p2 flun_id=>N/A dm_name=>N/A array_type=>LOCAL array_name=>N/A lun_id=>N/A shared=>NO
[1] => name=>vg2 type=>LVM lun_size=>1G mpath_name=>//dev/mapper/mpath28p1 flun_id=>60060e80166fa70000016fa700000013 dm_name=>/dev/dm-33 array_type=>R700 array_name=>LS1000 lun_id=>0013 shared=>NO
[2] => ....etc
感謝
我確實在每列之間都有差異空間。取決於列的長度。修正了首先通過使所有空格= 1。然後不得不修剪每行的尾隨空白。感謝大家的幫助。正是我需要的。 – debow