There has been lots and lots of discussion in CF blogs and forums about ListToArray not supporting empty elements. Seeing which I had blogged about a simple way which could do the same. Thanks to Charlie Griefer for pointing out the problem in it and then thanks to Ben Nadel and Andrew Clark for pointing me in the right direction.
Though it got pretty late, I was able to sneak-in this change in ColdFusion 8. ListToArray() now takes an additional optional argument “includeEmptyElements”, which if ‘true’ will include the empty elements of list into the array. Default is of course ‘false’. It also takes care of empty elements at the end of list and multiple delimiters. Here is how the function looks
ListToArray(list, delimiter, includeEmptyElements) returns Array
Lets take a look at couple of examples to see it working
<cfset list = "a,b,,c, ,d,,"> <cfset arr = ListToArray(list, ',', true)> <cfdump var="#arr#">
Here is how the output looks.
Here is another example.
<cfset list = "one,/$/,six"> <cfset arr = listToArray(list, ",$/",true)> <cfdump var="#arr#">
The output for which looks like this
Though we wanted to, there was just not enough time to make similar change in all the list functions for CF 8. Something for CF 9
As you can see, it gives you information like lastmodified time, mode in which the file was opened, name, path, size in bytes and status of this file object whether this is still open or closed.