本帖最后由 skyfree 于 2014-5-7 12:01 编辑
大概是这样的效果?
#include <Array.au3>
Opt('MustDeclareVars', 1)
_Main()
Exit
Func _Main()
Local $a_1DArray[] = ['张杰,男,北京,27', _
'刘阳,女,广州,23,学生', _
'李伟,男,上海,25']
_ArrayDisplay($a_1DArray, '$a_1DArray')
Local $a_2DArray = _Array_1D_to_2D($a_1DArray)
_ArrayDisplay($a_2DArray, '$a_2DArray')
EndFunc ;==>_Main
Func _Array_1D_to_2D(Const ByRef $a_1DArray)
Local $a_2DArray[1][1], $p = 0
Local $ta_Arr
Local $n = 1
Local $i, $j
For $i = 0 To UBound($a_1DArray, 1) - 1
$ta_Arr = StringSplit($a_1DArray[$i], ',')
;~ _ArrayDisplay($ta_Arr, '$ta_Arr')
If $ta_Arr[0] > $n Then $n = $ta_Arr[0]
ReDim $a_2DArray[$p + 1][$n]
For $j = 1 To $ta_Arr[0]
$a_2DArray[$p][$j - 1] = $ta_Arr[$j]
Next
$p += 1
Next
Return $a_2DArray
EndFunc ;==>_Array_1D_to_2D
|