phew Posted October 19, 2007 Share Posted October 19, 2007 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 More sharing options...
Kerros Posted October 19, 2007 Share Posted October 19, 2007 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 More sharing options...
phew Posted October 19, 2007 Author Share Posted October 19, 2007 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_1dimnow 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 Link to comment Share on other sites More sharing options...
phew Posted October 22, 2007 Author Share Posted October 22, 2007 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 More sharing options...
weaponx Posted October 22, 2007 Share Posted October 22, 2007 It would be a lot easier to help if you showed us examples of some strings returning 1 dimension and some returning 2 dimensions. 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