Jump to content
Sign in to follow this  

Converting Array 1D-2D

Recommended Posts



I have a file I can open and get Arrival Times of Buses:

$sArray = _StringBetween($hfile,"Arrival_Time:",">",-1)

that creates me an 1D Array

Every line is more or less:

[0] [Monday,  23:50]
[1] [Tuesday, 11:45]

I want, from this $sArray, to create a new 2D Array:


where i could have:

[2][...]    [...]

I tried StringSplit but it doesn't work so well.

Any suggestions?



Share this post

Link to post
Share on other sites

#include <array.au3>

Dim $aArray[2]
$aArray[0] = 'Monday,  23:50'
$aArray[1] = 'Tuesday, 11:45'

Dim $aArray2D[UBound($aArray)][2]

For $i = 0 To UBound($aArray)-1
    $aSplitted = StringSplit(StringStripWS($aArray[$i], 8), ',')

    If $aSplitted[0] <> 2 Then
        MsgBox(16, 'Error', 'Wrong text!')

    $aArray2D[$i][0] = $aSplitted[1]
    $aArray2D[$i][1] = $aSplitted[2]


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  


Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.