Jump to content

dimension variegating array


phew
 Share

Recommended Posts

hi,

i have an array, $www

$www = StringRegExp($srcv, '<a href="(.*?)" class=l>', 3)

now sometimes $www is 1-dimensional and sometimes it's 2-dimensional.

how to save all values in a 1-dimensional array (converting the $www[x][y] 2-dimensional arrays into a one-dimensional array)?

greetings

Link to comment
Share on other sites

This is the way that I take an Ini file and put it into a 1 Dimensional array

CODE

;$a is the ini file

;$b is the section of the ini file to be placed into a 1 Dimensional array

Func Loadini_1dim(ByRef $a, $<_<

$aArray = IniReadSection($a, $:)

Dim $aArray_1dim[uBound($aArray) ]

For $icc = 1 To UBound($aArray) - 1

$aArray_1dim[$icc] = $aArray[$icc][0] & "=" & $aArray[$icc][1]

Next

;~ _ArraySort($aArray_1dim, 0, 1)

Return $aArray_1dim

EndFunc ;==>Loadini_1dim

now in your case where it is sometimes a 1 dimensional and sometimes a two dimensional, you would probally want to do some error checking to find out what type of array it is first.

Hope that helps.

Kerros===============================================================How to learn scripting: Figure out enough to be dangerous, then ask for assistance.

Link to comment
Share on other sites

This is the way that I take an Ini file and put it into a 1 Dimensional array

CODE

;$a is the ini file

;$b is the section of the ini file to be placed into a 1 Dimensional array

Func Loadini_1dim(ByRef $a, $<_<

$aArray = IniReadSection($a, $:)

Dim $aArray_1dim[uBound($aArray) ]

For $icc = 1 To UBound($aArray) - 1

$aArray_1dim[$icc] = $aArray[$icc][0] & "=" & $aArray[$icc][1]

Next

;~ _ArraySort($aArray_1dim, 0, 1)

Return $aArray_1dim

EndFunc ;==>Loadini_1dim

now in your case where it is sometimes a 1 dimensional and sometimes a two dimensional, you would probally want to do some error checking to find out what type of array it is first.

Hope that helps.

thanks for the suggestion i'll try it later g2g now :P
Link to comment
Share on other sites

well i found some time now to continue with my script but i found no possibility to check if the "$www"-array is one- or twodimensional.

$www = StringRegExp($srcv, '<a href="(.*?)" class=l>', 3)

the stringregexp return values are:

Flag = 3 or 4 :
@Error Meaning 
0 Array is valid.  
1 Array is invalid. No matches. 
2 Bad pattern, array is invalid. @Extended = offset of error in pattern.

some help please!

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...