Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Splitting a String

Posted on 2004-08-03
7
Medium Priority
?
1,371 Views
Last Modified: 2013-12-20
I am trying to find a function in Coldfusion that is equivalent to the PHP explode function.

I have a string theDate = "7/3/04" and I want to seperate it by "/" into an array so that the first position in the array will be "7" then second will be "3" and the third will be "04". Can anyone give me a code example of how I can do this?
0
Comment
Question by:thecode101
[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
  • 3
7 Comments
 
LVL 4

Expert Comment

by:eclipse2k
ID: 11705285
You can handle it like it would be a list, but not delimited with , but with /, for example:

<cfset result = ListToArray(theDate, "/")>

You can also use

<cfset secondValue = ListGetAt(theDate, 2, "/")>


eclipse2k
0
 
LVL 3

Author Comment

by:thecode101
ID: 11705418
I tried this but it is not working.

<cfset result= ListToArray(#theDate#, "/")>
<cfset Month1 = result[0]>
#Month1#

returns the error:
The element at position 1 of dimension 1, of array variable &quot;RESULT,&quot; cannot be found.
0
 
LVL 17

Expert Comment

by:anandkp
ID: 11705527
<cfset result= ListToArray(theDate, "/")>
0
Nothing ever in the clear!

This technical paper will help you implement VMware’s VM encryption as well as implement Veeam encryption which together will achieve the nothing ever in the clear goal. If a bad guy steals VMs, backups or traffic they get nothing.

 
LVL 4

Expert Comment

by:eclipse2k
ID: 11705576
In Coldfusion, Arrays start at Position 1, not 0!
0
 
LVL 4

Accepted Solution

by:
eclipse2k earned 200 total points
ID: 11705587
Proper solution:

<cfset result= ListToArray(theDate, "/")>
<cfset Month1 = result[1]>
#Month1#
0
 
LVL 17

Expert Comment

by:anandkp
ID: 11705611
oops sorry - i didnt see that carefully ...

<cfset result=ArrayNew()>
<cfset result= ListToArray(theDate, "/")>

#result[0]#
0
 
LVL 17

Expert Comment

by:anandkp
ID: 11705635
yeah eclipse is correct - [0] wont work with CF it starts from [1] ... gosh its time for me to go home ... :)
0

Featured Post

Free Backup Tool for VMware and Hyper-V

Restore full virtual machine or individual guest files from 19 common file systems directly from the backup file. Schedule VM backups with PowerShell scripts. Set desired time, lean back and let the script to notify you via email upon completion.  

Question has a verified solution.

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

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.
This guide will walk you through the essential considerations and tech stack for building scalable websites. Know how to grow your business the smart way!
The purpose of this video is to demonstrate how to Test the speed of a WordPress Website. Site Speed is an important metric of a site’s health. Slow site speed can result in viewers leaving your site quickly and not seeing your content. This…
The purpose of this video is to demonstrate how to set up an RSS Feed on a WordPress Website. This will be demonstrated using a Windows 8 PC. Feedburner will be used for this demonstration. Go to your WordPress login page. This will look like the…
Suggested Courses

597 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