Recently there was a request on our forum to support empty elements in ListToArray function for Scorpio i.e ColdFusion 8. it might not be done in Scorpio since it is too late to add a new function. However it can be very easily achieved in cfm itself. Here is the code to do it.
<cfset cflist="a,b,,c,,,d"> <cfset cfarr1 = ListToArray(cflist)> <span style="text-decoration: line-through;"><cfset cfarr2 = cflist.split(",")></span> <cfset cfarr2 = cflist.split(",", -1)> <cfdump var="#cfarr1#"> <cfdump var="#cfarr2#"> <cfscript> for(i=1; i <= ArrayLen(cfarr2); i++) { writeoutput("Element #i# : #cfarr2[i]# <br>"); } </cfscript>
As you can see, 3rd, 5th and 6th element in this cfarr2 are empty.
