Sign in to follow this  
Followers 0
phew

dimension variegating array

5 posts in this topic

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

Share this post


Link to post
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.

Share this post


Link to post
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

Share this post


Link to post
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!

Share this post


Link to post
Share on other sites

It would be a lot easier to help if you showed us examples of some strings returning 1 dimension and some returning 2 dimensions.

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