Ask a Question related to Macromedia ColdFusion, Design and Development.
-
samb1 #1
Creating a 2dm array from a list
I have a list of hrefs from three different sites which I have then stored into
a 1dm array. There are around 40 elements (href's)in the 1dm array. To manage
the hrefs more efficiently Im trying to create a 2dm array from the list. Where
the first dimension is the site and the second element are the links within
each site (hrefs). Is this possible? And if so how? (Confused) Thanks in
advance
samb1 Guest
-
List from array .as
in this code ... the list is reading from Array ... but i can not display the name of each of them... ... if you click the button, and then... -
array -> list
Is there a way to convert an array to a (parameter-)list? I often find myself doing things like: year,mon,day,hour,minute =... -
[PHP] Array to List
All, Thanks for your help, but this shouldn't be so freaking hard to do. <sigh> 1) I have a multiple select input on one page that is populated... -
Array to List
Hello, Coming from ColdFusion, this is difficult. CF has an ArrayToList() function. I can't find anything similar in PHP. I'm building a list... -
list question (creating one list out of many)
Actually it would be: on parselist gList,whichList thisMany = which.count -- you don't want to be counting the list at each repeat loop repeat... -
jdeline #2
Re: Creating a 2dm array from a list
Tell me more about the structure of your list. Is it like site1,href1,site1,href2,site2,href3,...?
jdeline Guest
-
samb1 #3
Re: Creating a 2dm array from a list
Yes the structure of the list is href=webite1?id01 href=webite1?id02
href=webite1?id03 href=webite2?id01 href=webite2?id02 href=webite3?id01
href=webite1?id02 etc What I have done is loop over 3 different index pages
and then use 3 different regex to parse each index page for specific links.
Those links have then been added straight into a 1dm array. Here is some of y
code: <cfset xmlObj = xmlParse( xmlString ) /> <!---Loop through the XML
doc elements---> <cfloop from='1' to='#arrayLen( xmlObj.xmlRoot.xmlChildren
)#' index='i'> <!---HTTP Call each site index attribute from the XML--->
<cfhttp method='get' URL='#Trim(xmlObj.xmlRoot.site.xmlAttributes.index )#'
ResolveURL='no'> <cfset StartPos = 1> <cfloop condition ='True'>
<!---Parse the site index pages for job links---> <cfset Match =
REFindNoCase(#Trim(xmlObj.xmlRoot.site.parse.xmlAt tributes.re)#,
cfhttp.FileContent, StartPos, True)> <cfif Match.pos[1] EQ 0>
<cfbreak> <cfelse> <cfset StartPos = Match.pos[1] +
Match.len[1]> <cfset Foundlinks = Mid(cfhttp.FileContent, Match.pos[1],
Match.len[1])> <cfset StripLinks =
#REReplaceNoCase(#Mid(cfhttp.FileContent, Match.pos[1], Match.len[1])#,'=['']',
'http://www.rspb.org.uk/vacancies/index.asp', 'ALL')#>---> </cfif>
</cfloop> <!---Store the list of FoundLinks into the Links Array--->
<cfset LinksArray = ListToArray(StripLinks)>
samb1 Guest
-
jdeline #4
Re: Creating a 2dm array from a list
Is the list comma delimited? In other words, is it like the list below?
href=webite1?id01,
href=webite1?id02,
href=webite1?id03,
href=webite2?id01,
href=webite2?id02,
href=webite3?id01,
href=webite1?id02
If so, code something like that shown below might work.
<CFSET sites = ArrayNew(2)>
<CFSET n = 1>
<CFLOOP LIST="siteList" INDEX="i">
<CFSET found = Find("?", i)>
<CFSET sites[n][1] = Mid(i, 1, found - 1)>
<CFSET sites[n][2] = Mid(i, found + 1, 999)>
<CFSET n = n + 1>
</CFLOOP>
jdeline Guest
-
samb1 #5
Re: Creating a 2dm array from a list
Thanks for that jdeline but I get an error when trying to dump '#sites[n][1]#'
Parameter 3 of function Mid which is now -1 must be a non-negative integer
The error occurred in C:\CFusionMX\wwwroot\Project\1.cfm: line 35 33 :
<CFLOOP LIST='StripLinks' INDEX='i'> 34 : <CFSET found = Find('?',
i)> 35 : <CFSET sites[n][1] = Mid(i, 1, found -1)> 36 : <CFSET
sites[n][2] = Mid(i, found + 1, 999)> 37 : <CFSET n = n + 1> Any
ideas? Thanks
samb1 Guest



Reply With Quote

