[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Array parse

Posted on 2008-06-09
5
Medium Priority
?
167 Views
Last Modified: 2013-12-24
I have a variables set in a cookie. It can have a max of three variables, e.g. (17000,18234,21345)
I've tried to loop through them with no success. I need to loop through the cookie and pull each value out and assign the cookie name (CFID) and number to it. For example the first value would be CIDS1 and the second, CIDS2, etc.

<cfset arr = ArrayNew(1)>
<cfloop index="i" list="#CIDS#" delimiters=",">
  <cfset ArrayAppend(arr, i)>
</cfloop>
0
Comment
Question by:usky1
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 

Author Comment

by:usky1
ID: 21746545
I forgot to add the rest of the loop,
<cfloop index="j" from="1" to="#ArrayLen(arr)#">
 <cfoutput> #arr[j]# </cfoutput>
</cfloop>
0
 
LVL 25

Accepted Solution

by:
dgrafx earned 2000 total points
ID: 21751264
I guess I don't quite get what you are trying to do (not that it's that important that I understand)
1) you have one cookie whose value is a comma delimited list - correct?
2) you want to loop through this value and create new variables for each one - is that correct?

something like this?
<cfset cids="123,456,789">
<cfset counter=0>
<cfloop index="i" list="#CIDS#" delimiters=",">
<cfset counter=counter+1>
      <cfset "CIDS#counter#"=i>
</cfloop>
<cfloop index="j" from="1" to="#counter#">
<cfoutput>#variables["CIDS" & j]#</cfoutput><br>
</cfloop>

if this isn't close please provide info as to what you want to do in the end - i.e. the concept
0
 

Author Comment

by:usky1
ID: 21751704
1) you have one cookie whose value is a comma delimited list - correct? yes
2) you want to loop through this value and create new variables for each one - is that correct? yes
Sorry for the question confusion. I need to loop through each cookie value and create a new one. For example,
If the cookies first value is 123 I need to do a <cfset number1 = 123>
If the second is 456 then <<cfset number2 = 456>
There are not always three values, there might not even be any depending on previous functions.
How can I loop through and add the cfsets, if existing?
0
 
LVL 25

Expert Comment

by:dgrafx
ID: 21751847
see the code i posted above
this will loop and set the number of vars that you have in your list
if you have  a list of 2 then 2 vars will be set
if you have 5 then 5 will be set
try it out ...

note that the last cfloop in my example is not part of the code but just a way for you to see what has been set
0
 

Author Comment

by:usky1
ID: 21752089
Works great. thanks for your help.
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Have you ever sent email via ColdFusion and thought of tracking this mail to capture the exact date and time when the message was opened ?  If yes, then this article is for you ! First we need a table user_email with columns user_id , email , sub…
If you don't have the right permissions set for your WordPress location in IIS, you won't be able to perform automatic updates. Here's how to fix the problem.
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…

656 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question