stracqan
asked on
How do I split a complex URL string in Coldfusion?
Hello,
I have a URL string with multiple query parameters. What I would like to do is use a <cfscript function to split the string based on each variable and then build an array with it that will be returned.
In other words, say I have the following URL string:
www.example.com/test.cfm?test1=foo&test2=foo2&test3=foo3
What I woudl like to do is pass that string into a function and then output the variables in an array.
Example of outputted array: ( I know this is not what it looks like when you dump it, but I'm sure you know what I mean.)
test1 | foo
test2 | foo2
test3 | foo3
Thank you very much in advance!!!!
I have a URL string with multiple query parameters. What I would like to do is use a <cfscript function to split the string based on each variable and then build an array with it that will be returned.
In other words, say I have the following URL string:
www.example.com/test.cfm?test1=foo&test2=foo2&test3=foo3
What I woudl like to do is pass that string into a function and then output the variables in an array.
Example of outputted array: ( I know this is not what it looks like when you dump it, but I'm sure you know what I mean.)
test1 | foo
test2 | foo2
test3 | foo3
Thank you very much in advance!!!!
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Worked Perfectly!!! Thanks!!!!!!!!!
>> LISTFIRST(thisparam,"=")
Just watch out for empty values. CF list functions tend to ignore those. If you think you might have empty values like: something=(empty value)
www.example.com/test.cfm?test1=foo&something=
Then you might want to use ListToArray(string, delim, preserveEmptyElements) instead.