Sign in to follow this  
Followers 0
IchBistTod

Turn a multi dimensional array into a string

4 posts in this topic

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]

Share this post


Link to post
Share on other sites



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)

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

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]

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0