IchBistTod Posted December 9, 2009 Share Posted December 9, 2009 How do i turn a multi-dimensional array into a string from left to right, top to bottom, using a"|" to separate each value? [center][/center][center]=][u][/u][/center][center][/center] Link to comment Share on other sites More sharing options...
turbov21 Posted December 9, 2009 Share Posted December 9, 2009 How do i turn a multi-dimensional array into a string from left to right, top to bottom, using a"|" to separate each value? Dim $names[3][3], $str $names[0][0] = "x" $names[0][1] = "y" $names[0][2] = "z" $names[1][0] = "a" $names[1][1] = "b" $names[1][2] = "c" $names[2][0] = "d" $names[2][1] = "e" $names[2][2] = "f" For $i = 0 to UBound($names, 1)-1 For $j = 0 to UBound($names, 2)-1 $str &= $names[$i][$j] If $j < UBound($names, 2)-1 Then $str &= "|" Next If $i < UBound($names, 1)-1 Then $str &= "|" Next MsgBox(0, "", $str) Link to comment Share on other sites More sharing options...
whim Posted December 9, 2009 Share Posted December 9, 2009 Something like this, maybe ? Dim $arr[$a][$b] For $i = 0 To $a - 1 For $j = 0 To $b -1 $string &= "|" & $arr[$i][$j] Next Next $string = StringTrimLeft($string, 1) ; remove extra "|" before first element Of course it is a matter of opinion/choice which dimension you choose to represent rows/columns, so swap to taste ... whim Link to comment Share on other sites More sharing options...
IchBistTod Posted December 10, 2009 Author Share Posted December 10, 2009 thanks for all your help, I know I have been asking a lot lately, But I am suffering from depression and can not think clearly. [center][/center][center]=][u][/u][/center][center][/center] Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now