Copy link to clipboard
Copied
I would like to take a number such as "12345" and turn it into a list or array such as "1,2,3,4,5". I am using this for my hit counter. I am able to return the value out of a database but would like each individual number to correspond to an image file.
PLEASE HELP
Does it have to be an array?
You can easily loop around the length of the string, and then extract that character for your number file.
<cfloop from="1" to="#Len('12345')#" index="i">
<cfset numInFocus = Mid('12345', i, 1)>
... process loading image ...
</cfloop>
Dave @ Oyova Software
Copy link to clipboard
Copied
Does it have to be an array?
You can easily loop around the length of the string, and then extract that character for your number file.
<cfloop from="1" to="#Len('12345')#" index="i">
<cfset numInFocus = Mid('12345', i, 1)>
... process loading image ...
</cfloop>
Dave @ Oyova Software
Copy link to clipboard
Copied
Thanx. That worked perfect. Using this forum was alot faster than searching around on GOOGLE.
Copy link to clipboard
Copied
I thought I heard once that one can create a character array by using a list function with no delimiter.
<cfset charArray = listToArray("12345","")>
<cfdump var="#charArray#">
Untested, but may be worth a try.
Copy link to clipboard
Copied
<cfset charArray = listToArray("12345","")> <cfdump var="#charArray#">
Hi Ian
That doesn't work on CF8, but it perhaps works on CF9 (I don't have a CF9 box here).
However this does work on CF8:
<cfset charArray = listToArray(reReplace("12345","(.)", "\1,", "ALL"))>
That said, the posting above marked as "the answer" is as good as any.
--
Adam
Copy link to clipboard
Copied
However this does work on CF8:
<cfset charArray = listToArray(reReplace("12345","(.)",
"\1,", "ALL"))>
Haha. Sneaky.
-Leigh
Copy link to clipboard
Copied
I thought I heard once that one can create a character
array by using a list function with no delimiter.
<cfset charArray = listToArray("12345","")>
Yep. I would have to double check it, but ... I believe that works in CF9 only.
Get ready! An upgraded Adobe Community experience is coming in January.
Learn more