- CFML Reference User Guide
- ColdFusion functions
- ColdFusion functions by category
- Functions a-b
- Abs
- ACos
- AddSOAPRequestHeader
- AddSOAPResponseHeader
- AjaxLink
- AjaxOnLoad
- ApplicationStop
- ArrayAppend
- ArrayAvg
- ArrayClear
- ArrayContains
- ArrayContainsNoCase
- ArrayDelete
- ArrayDeleteAt
- ArrayDeleteNoCase
- ArrayEach
- ArrayFilter
- ArrayFind
- ArrayFindAll
- ArrayFindAllNoCase
- ArrayFindNoCase
- ArrayInsertAt
- ArrayIsDefined
- ArrayIsEmpty
- ArrayLen
- ArrayMap
- ArrayMax
- ArrayMin
- ArrayNew
- ArrayPrepend
- ArrayReduce
- ArrayResize
- ArraySet
- ArraySetMetadata
- ArraySlice
- ArraySort
- ArraySum
- ArraySwap
- ArrayToList
- Asc
- ASin
- Atn
- AuthenticatedContext
- AuthenticatedUser
- BinaryDecode
- BinaryEncode
- BitAnd
- BitMaskClear
- BitMaskRead
- BitMaskSet
- BitNot
- BitOr
- BitSHLN
- BitSHRN
- BitXor
- BooleanFormat
- Abs
- Functions-c-d
- CacheGet
- CacheGetAllIds
- CacheGetMetadata
- CacheGetProperties
- CacheGetSession
- CacheIdExists
- CachePut
- CacheRegionExists
- CacheRegionNew
- CacheRegionRemove
- CacheRemove
- CacheRemoveAll
- CacheSetProperties
- CallStackDump
- CallStackGet
- CanDeSerialize
- Canonicalize
- CanSerialize
- Ceiling
- CharsetDecode
- CharsetEncode
- Chr
- CJustify
- Compare
- CompareNoCase
- Cos
- CreateDate
- CreateDateTime
- CreateObject
- CreateObject: .NET object
- CreateObject: COM object
- CreateObject: component object
- CreateObject: CORBA object
- CreateObject: Java or EJB object
- CreateObject: web service object
- CreateODBCDate
- CreateODBCDateTime
- CreateODBCTime
- CreateSignedJWT
- CreateEncryptedJWT
- CreateTime
- CreateTimeSpan
- CreateUUID
- CSRFGenerateToken
- CSRFVerifyToken
- CSVRead
- CSVWrite
- CSVProcess
- DateAdd
- DateCompare
- DateConvert
- DateDiff
- DateFormat
- DatePart
- DateTimeFormat
- Day
- DayOfWeek
- DayOfWeekAsString
- DayOfYear
- DaysInMonth
- DaysInYear
- DE
- DecimalFormat
- DecodeForHTML
- DecodeFromURL
- DecrementValue
- Decrypt
- DecryptBinary
- DeleteClientVariable
- Deserialize
- DeserializeJSON
- DeserializeXML
- DirectoryCopy
- DirectoryCreate
- DirectoryDelete
- DirectoryExists
- DirectoryList
- DirectoryRename
- DollarFormat
- DotNetToCFType
- Duplicate
- Functions-e-g
- EncodeForCSS
- EncodeForDN
- EncodeForHTML
- EncodeForHTMLAttribute
- EncodeForJavaScript
- EncodeForLDAP
- EncodeForURL
- EncodeForXML
- EncodeForXMLAttribute
- EncodeForXpath
- Encrypt
- EncryptBinary
- EntityDelete
- EntityLoad
- EntityLoadByExample
- EntityLoadByPK
- EntityMerge
- EntityNew
- EntityReload
- EntitySave
- EntityToQuery
- Evaluate
- Exp
- ExpandPath
- FileClose
- FileCopy
- FileDelete
- FileExists
- FileGetMimeType
- FileIsEOF
- FileMove
- FileOpen
- FileRead
- FileReadBinary
- FileReadLine
- FileSeek
- FileSetAccessMode
- FileSetAttribute
- FileSetLastModified
- FileSkipBytes
- FileUpload
- FileUploadAll
- FileWrite
- FileWriteLine
- Find
- FindNoCase
- FindOneOf
- FirstDayOfMonth
- Fix
- Floor
- FormatBaseN
- GeneratePBKDFKey
- GenerateSecretKey
- GetApplicationMetadata
- GetAuthUser
- GetBaseTagData
- GetBaseTagList
- GetBaseTemplatePath
- GetClientVariablesList
- GetComponentMetaData
- GetContextRoot
- GetCPUUsage
- GetCurrentTemplatePath
- GetCSPNonce
- GetDirectoryFromPath
- GetEncoding
- GetException
- GetFileFromPath
- GetFileInfo
- GetFreeSpace
- GetFunctionCalledName
- GetFunctionList
- GetGatewayHelper
- GetHttpRequestData
- GetHttpTimeString
- GetK2ServerDocCount
- GetK2ServerDocCountLimit
- GetLocale
- GetLocaleDisplayName
- GetLocalHostIP
- GetMetaData
- GetMetricData
- GetPageContext
- GetPropertyString
- GetPropertyFile
- GetPrinterInfo
- GetPrinterList
- GetProfileSections
- GetProfileString
- GetReadableImageFormats
- GetSafeHTML
- GetSAMLAuthRequest
- GetSAMLLogoutRequest
- Generate3DesKey
- GenerateSAMLSPMetadata
- GetSOAPRequest
- GetSOAPRequestHeader
- GetSOAPResponse
- GetSOAPResponseHeader
- GetSystemFreeMemory
- GetSystemTotalMemory
- GetTempDirectory
- GetTempFile
- GetTemplatePath
- GetTickCount
- GetTimeZoneInfo
- GetToken
- GetTotalSpace
- GetUserRoles
- GetVFSMetaData
- GetWriteableImageFormats
- Functions-h-im
- Hash
- HMac
- Hour
- HQLMethods
- HTMLCodeFormat
- HTMLEditFormat
- IIf
- ImageAddBorder
- ImageBlur
- ImageClearRect
- ImageCopy
- ImageCreateCaptcha
- ImageCrop
- ImageDrawArc
- ImageDrawBeveledRect
- ImageDrawCubicCurve
- ImageDrawLine
- ImageDrawLines
- ImageDrawOval
- ImageDrawPoint
- ImageDrawQuadraticCurve
- ImageDrawRect
- ImageDrawRoundRect
- ImageDrawText
- ImageFlip
- ImageGetBlob
- ImageGetBufferedImage
- ImageGetEXIFMetadata
- ImageGetEXIFTag
- ImageGetHeight
- ImageGetIPTCMetadata
- ImageGetIPTCTag
- ImageGetMetadata
- ImageGetWidth
- ImageGrayscale
- ImageInfo
- ImageMakeColorTransparent
- ImageMakeTranslucent
- ImageNegative
- ImageNew
- ImageOverlay
- ImagePaste
- ImageRead
- ImageReadBase64
- ImageResize
- ImageRotate
- ImageRotateDrawingAxis
- ImageScaleToFit
- ImageSetAntialiasing
- ImageSetBackgroundColor
- ImageSetDrawingColor
- ImageSetDrawingStroke
- ImageSetDrawingTransparency
- ImageSharpen
- ImageShear
- ImageShearDrawingAxis
- ImageTranslate
- ImageTranslateDrawingAxis
- ImageWrite
- ImageWriteBase64
- ImageXORDrawingMode
- Functions-in-k
- IncrementValue
- InputBaseN
- Insert
- Int
- InterruptThread
- InvalidateOauthAccesstoken
- Invoke
- InitSAMLAuthRequest
- InitSAMLLogoutRequest
- InvokeCFClientFunction
- IsArray
- IsAuthenticated
- IsAuthorized
- IsBinary
- IsBoolean
- IsClosure
- IsCustomFunction
- IsDate
- IsDateObject
- IsDDX
- IsDebugMode
- IsDefined
- IsImage
- IsImageFile
- IsInstanceOf
- IsIPv6
- IsJSON
- IsK2ServerABroker
- IsK2ServerDocCountExceeded
- IsK2ServerOnline
- IsLeapYear
- IsLocalHost
- IsNull
- IsNumeric
- IsNumericDate
- IsObject
- isOnline
- IsPDFArchive
- IsPDFFile
- IsPDFObject
- IsProtected
- IsQuery
- isSamlLogoutResponse
- isSafeHTML
- IsSimpleValue
- IsSOAPRequest
- IsSpreadsheetFile
- IsSpreadsheetObject
- IsStruct
- isThreadInterrupted
- IsUserInAnyRole
- IsUserInRole
- IsUserLoggedIn
- IsValid
- IsValidOauthAccesstoken
- IsWDDX
- IsXML
- IsXmlAttribute
- IsXmlDoc
- IsXmlElem
- IsXmlNode
- IsXmlRoot
- JavaCast
- JSStringFormat
- Functions-l
- LCase
- Left
- Len
- ListAppend
- ListChangeDelims
- ListContains
- ListContainsNoCase
- ListDeleteAt
- ListEach
- ListFilter
- ListFind
- ListFindNoCase
- ListFirst
- ListGetAt
- ListGetDuplicates
- ListInsertAt
- ListLast
- ListLen
- ListMap
- ListPrepend
- ListQualify
- ListReduce
- ListRemoveDuplicates
- ListRest
- ListSetAt
- ListSort
- ListToArray
- ListValueCount
- ListValueCountNoCase
- LJustify
- Location
- Log
- Log10
- LSCurrencyFormat
- LSDateFormat
- LSDateTimeFormat
- LSEuroCurrencyFormat
- LSIsCurrency
- LSIsDate
- LSIsNumeric
- LSNumberFormat
- LSParseCurrency
- LSParseDateTime
- LSParseEuroCurrency
- LSParseNumber
- LSTimeFormat
- LTrim
- Functions-m-r
- Max
- Mid
- Min
- Minute
- Month
- MonthAsString
- Now
- NumberFormat
- ObjectEquals
- ObjectLoad
- ObjectSave
- OnWSAuthenticate
- ORMClearSession
- ORMCloseAllSessions
- ORMCloseSession
- ORMEvictCollection
- ORMEvictEntity
- ORMEvictQueries
- ORMExecuteQuery
- ORMFlush
- ORMFlushall
- ORMGetSession
- ORMGetSessionFactory
- ORMIndex
- ORMIndexPurge
- ORMReload
- ORMSearch
- ORMSearchOffline
- ParagraphFormat
- ParameterExists
- ParseDateTime
- Pi
- PrecisionEvaluate
- ProcessSAMLResponse
- ProcessSAMLLogoutRequest
- Quarter
- PreserveSingleQuotes
- QueryAddColumn
- QueryAddRow
- QueryConvertForGrid
- QueryExecute
- QueryFilter
- QueryGetResult
- QueryGetRow
- QueryKeyExists
- QueryMap
- QueryNew
- QueryReduce
- QuerySetCell
- QuotedValueList
- QueryEach
- Rand
- Randomize
- RandRange
- ReEscape
- REFind
- REFindNoCase
- ReleaseComObject
- REMatch
- REMatchNoCase
- RemoveCachedQuery
- RemoveChars
- RepeatString
- Replace
- ReplaceList
- ReplaceNoCase
- REReplace
- REReplaceNoCase
- RestDeleteApplication
- RestSetResponse
- RestInitApplication
- Reverse
- Right
- RJustify
- Round
- RTrim
- Functions-s
- Second
- SendGatewayMessage
- SendSAMLLogoutResponse
- Serialize
- SerializeJSON
- SerializeXML
- SessionInvalidate
- SessionRotate
- SessionGetMetaData
- SessionInvalidate
- SessionRotate
- SetDay
- SetEncoding
- SetHour
- SetLocale
- SetMonth
- SetProfileString
- SetPropertyString
- SetVariable
- SetYear
- Sgn
- Sin
- Sleep
- SpanExcluding
- SpanIncluding
- SpreadsheetAddAutoFilter
- SpreadsheetAddColumn
- SpreadsheetAddFreezePane
- SpreadsheetAddImage
- SpreadsheetAddInfo
- SpreadsheetAddPageBreaks
- SpreadsheetAddRow
- SpreadsheetAddRows
- SpreadsheetAddSplitPane
- SpreadsheetCreateSheet
- SpreadsheetDeleteColumn
- SpreadsheetDeleteColumns
- SpreadsheetDeleteRow
- SpreadsheetDeleteRows
- SpreadsheetFormatCell
- SpreadsheetFormatColumn
- SpreadsheetFormatCellRange
- SpreadsheetFormatColumn
- SpreadsheetFormatColumns
- SpreadsheetFormatRow
- SpreadsheetFormatRows
- SpreadsheetGetCellComment
- SpreadsheetGetCellFormula
- SpreadsheetGetCellValue
- SpreadsheetGetColumnCount
- SpreadsheetInfo
- SpreadsheetMergeCells
- SpreadsheetNew
- SpreadsheetRead
- SpreadsheetReadBinary
- SpreadsheetRemoveSheet
- SpreadsheetSetActiveSheet
- SpreadsheetSetActiveSheetNumber
- SpreadsheetSetCellComment
- SpreadsheetSetCellFormula
- SpreadsheetSetCellValue
- SpreadsheetSetColumnWidth
- SpreadsheetSetFooter
- SpreadsheetSetHeader
- SpreadsheetSetRowHeight
- SpreadsheetShiftColumns
- SpreadsheetShiftRows
- SpreadsheetWrite
- StreamingSpreadsheetNew
- StreamingSpreadsheetCleanup
- StreamingSpreadsheetRead
- StreamingSpreadsheetProcess
- SpreadsheetSetFooterImage
- SpreadsheetSetHeaderImage
- SpreadsheetSetFittoPage
- SpreadsheetUngroupColumns
- SpreadsheetGroupColumns
- SpreadsheetUngroupRows
- SpreadsheetGroupRows
- SpreadsheetRemoveColumnBreak
- SpreadsheetSetColumnBreak
- SpreadsheetRemoveRowBreak
- SpreadsheetSetRowBreak
- SpreadsheetRemovePrintGridlines
- SpreadsheetAddPrintGridlines
- SpreadsheetGetColumnWidth
- SpreadsheetSetColumnHidden
- SpreadsheetSetRowHidden
- SpreadsheetisColumnHidden
- SpreadsheetisRowHidden
- SpreadsheetisStreamingXmlFormat
- SpreadsheetisXmlFormat
- SpreadsheetisBinaryFormat
- SpreadsheetRenameSheet
- SpreadsheetRemoveSheetNumber
- SpreadsheetGetLastRowNumber
- SpreadsheetGetPrintOrientation
- Sqr
- StripCR
- StructAppend
- StructClear
- StructCopy
- StructCount
- StructDelete
- StructEach
- StructFilter
- StructFind
- StructFindKey
- StructFindValue
- StructGet
- StructGetMetadata
- StructInsert
- StructIsEmpty
- StructKeyArray
- StructKeyExists
- StructKeyList
- StructMap
- StructNew
- StructReduce
- StructSetMetadata
- StructSort
- StructToSorted
- StructUpdate
- StructValueArray
- StoreSetMetadata
- StoreGetACL
- StoreGetMetadata
- StoreAddACL
- StoreSetACL
- Functions-t-z
- Tan
- ThreadJoin
- ThreadTerminate
- Throw
- TimeFormat
- ToBase64
- ToBinary
- ToScript
- ToString
- Trace
- Transactionandconcurrency
- TransactionCommit
- TransactionRollback
- TransactionSetSavePoint
- Trim
- UCase
- URLDecode
- URLEncodedFormat
- URLSessionFormat
- Val
- ValueList
- VerifyClient
- Week
- Wrap
- WriteDump
- WriteLog
- WriteOutput
- WSGetAllChannels
- WSGetSubscribers
- WSPublish
- WSSendMessage
- XmlChildPos
- XmlElemNew
- XmlFormat
- XmlGetNodeType
- XmlNew
- XmlParse
- XmlSearch
- XmlTransform
- XmlValidate
- Year
- YesNoFormat
- ColdFusion tags
- ColdFusion tag summary
- ColdFusion tags by category
- Application framework tags
- Communications tags
- Database manipulation tags
- Data output tags
- Debugging tags
- Exception handling tags
- Extensibility tags
- File management tags
- Flow-control tags
- Forms tags
- Internet Protocol tags
- Page processing tags
- Security tags
- Variable manipulation tags
- Other tags
- Tags a-b
- Tags c
- cfcache
- cfcalendar
- cfcase
- cfcatch
- cfchart
- cfchart tag in ColdFusion
- Get started with cfchart
- Customize a chart using cfchart
- Advanced cfchart customization options
- Create an area chart in ColdFusion
- Create line charts in ColdFusion
- Create bar charts in ColdFusion
- Create floating bar charts in ColdFusion
- Create histograms in ColdFusion
- Create pie charts in ColdFusion
- Create funnel charts in ColdFusion
- Create pyramid charts in ColdFusion
- Create curve charts in ColdFusion
- Create boxplots in ColdFusion
- Create donut charts in ColdFusion
- Create bubble charts in ColdFusion
- Create scatterplots in ColdFusion
- Create radar charts in ColdFusion
- Other chart types in ColdFusion (Cone, Cylinder, Piano, and Bullet)
- Advanced customization options in cfchart
- cfchartdata
- cfchartseries
- cfchartset
- cfclient
- cfclientsettings
- cfcol
- cfcollection
- cfcomponent
- cfcontent
- cfcontinue
- cfcookie
- Tags f
- cffeed
- cffile
- cffile action = "append"
- cffile action = "copy"
- cffile action = "delete"
- cffile action = "move"
- cffile action = "read"
- cffile action = "readBinary"
- cffile action = "rename"
- cffile action = "upload"
- cffile action = "uploadAll"
- cffile action = "write"
- cffileupload
- cffinally
- cfflush
- cfform
- cfformgroup
- cfformitem
- cfftp
- cfftp: Connection: file and directory operations
- cfftp: Opening and closing FTP server connections
- cfftp : Opening and closing secure FTP server connections
- cfftp action = "listDir"
- cffunction
- Tags g-h
- Tags i
- Tags j-l
- cfjava
- cflayout
- cflayoutarea
- cfldap
- cflocation
- cflock
- cflog
- cflogin
- cfloginuser
- cflogout
- cfloop
- cfloop : conditional loop
- cfloop : index loop
- cfloop : looping over a COM collection or structure
- cfloop : looping over a date or time range
- cfloop : looping over a list, a file, or an array
- cfloop : looping over a query
- Tags m-o
- cfmail
- cfmailparam
- cfmailpart
- cfmap
- cfmapitem
- cfmediaplayer
- cfmenu
- cfmenuitem
- cfmessagebox
- cfmodule
- cfNTauthenticate
- cfoauth
- cfobject
- cfobject: .NET object
- cfobject: COM object
- cfobject: component object
- cfobject: CORBA object
- cfobject: Java or EJB object
- cfobject: web service object
- cfobjectcache
- cfoutput
- Tags p-q
- Tags r-s
- Tags t
- Tags u-z
- CFML Reference
- Reserved words and variables
- Ajax JavaScript functions
- Ajax JavaScript functions
- Function summary Ajax
- ColdFusion.Ajax.submitForm
- ColdFusion.Autosuggest.getAutosuggestObject
- ColdFusion.Layout.enableSourceBind
- ColdFusion.MessageBox.getMessageBoxObject
- ColdFusion.ProgressBar.getProgressBarObject
- ColdFusion.MessageBox.isMessageBoxDefined
- JavaScriptFunctionsinColdFusion9Update1
- ColdFusion ActionScript functions
- ColdFusion mobile functions
- Application.cfc reference
- Script functions implemented as CFCs
- ColdFusion Flash Form style reference
- Styles valid for all controls
- Styles for cfform
- Styles for cfformgroup with horizontal or vertical type attributes
- Styles for box-style cfformgroup elements
- Styles for cfformgroup with accordion type attribute
- Styles for cfformgroup with tabnavigator type attribute
- Styles for cfformitem with hrule or vrule type attributes
- Styles for cfinput with radio, checkbox, button, image, or submit type attributes
- Styles for cftextarea tag and cfinput with text, password, or hidden type attributes
- Styles for cfselect with size attribute value of 1
- Styles for cfselect with size attribute value greater than 1
- Styles for cfcalendar tag and cfinput with dateField type attribute
- Styles for the cfgrid tag
- Styles for the cftree tag
- ColdFusion Flash Form Style Reference
- ColdFusion event gateway reference
- ColdFusion Event Gateway reference
- addEvent
- CFEvent
- CFEventclass
- Constructor
- Gateway development interfaces and classes
- getStatus
- setCFCPath
- setCFCMethod
- getOriginatorID
- getLogger
- getBuddyList
- getBuddyInfo
- IM gateway message sending commands
- IM Gateway GatewayHelper class methods
- onIncomingMessage
- onIMServerMessage
- onBuddyStatus
- onAddBuddyResponse
- onAddBuddyRequest
- IM Gateway CFC incoming message methods
- IM gateway methods and commands
- CFML CFEvent structure
- warn
- info
- setOriginatorID
- data command
- submit Multi command
- submit command
- setGatewayType
- setGatewayID
- setData
- setCFCListeners
- outgoingMessage
- getStatusTimeStamp
- numberOfMessagesReceived
- numberOfMessagesSent
- removeBuddy
- removeDeny
- removePermit
- setNickName
- setPermitMode
- setStatus
- SMS Gateway CFEvent structure and commands
- SMS Gateway incoming message CFEvent structure
- getStatusAsString
- getProtocolName
- getPermitMode
- getPermitList
- getNickName
- getName
- getDenyList
- getCustomAwayMessage
- getQueueSize
- getMaxQueueSize
- getHelper
- getGatewayType
- getGatewayServices
- getGatewayID_1
- getGatewayID
- getData
- getCFCTimeout
- setCFCTimeout
- getCFCPath
- getCFCMethod
- GatewayServices class
- Gateway interface
- GatewayHelper interface
- addPermit
- addDeny
- addBuddy
- error
- debug
- Logger class
- stop
- start
- CFML event gateway SendGatewayMessage data parameter
- restart
- fatal
- SMS gateway message sending commands
- ColdFusion C++ CFX Reference
- ColdFusion Java CFX reference
- WDDX JavaScript Objects
- Cloud services
- ColdFusion and GCP Storage
- ColdFusion and GCP Firestore
- ColdFusion and GCP PubSub
- ColdFusion and Amazon S3
- ColdFusion and DynamoDB
- ColdFusion and Amazon SQS
- ColdFusion and Amazon SNS
- ColdFusion and MongoDB
- ColdFusion and Azure Blob
- ColdFusion and Azure Service Bus
- Multi-cloud storage services
- Multi-cloud RDS databases
- ColdFusion and Azure Cosmos DB
Description
Copies the elements of a list to an array.
Returns
An array
Category
Array functions, Conversion functions, List functions
Function syntax
ListToArray(list [, delimiters[, includeEmptyFields[, multiCharacterDelimiter]]])
See also
ArrayToList; Using Arrays and Structures in the Developing ColdFusion Applications
History
ColdFusion 9: Added the multiCharacterDelimiter parameter.
Parameters
Parameter |
Description |
|---|---|
list |
A list or a variable that contains one.You define a list variable with a cfset statement. |
delimiters |
A string or a variable that contains one. ColdFusion treats each character in the string as a delimiter. The default value is comma. |
includeEmptyFields |
A Boolean value specifying whether to create empty array entries if there are two delimiters in a row.
|
multiCharacterDelimiter |
A Boolean value specifying whether the delimiters parameter specifies a multi-character delimiter. The default is false. If this parameter is true, the delimiters parameter must specify a single delimiter consisting of multiple characters. This parameter enables the ListToArray function to convert a list such as the following to an array of color names: red:|orange:|yellow:|green:|blue:|indigo:|violet. |
Usage
ColdFusion, by default, ignores empty list elements; thus, the list "a,b,c,,,d" has four elements.ColdFusion treats each character in the delimiters parameter as a separate delimiter. Therefore, if the parameter is ",+" ColdFusion will break the list at either a comma or a plus sign.If you specify a multiCharacterDelimiter parameter, all list elements must be separated by exactly the specified characters. For example, the following code creates an array with three entries, "red, orange", "yellow, green" and "blue, violet".
<cfset list = "red,orange,&yellow,green,&blue,violet"> <cfset arr = listToArray (list, ",&",false,true)>
Example 1
<cfscript>
myList="ten;twenty;thirty;fort;fifty;sixty;;seventy;;;eighty"; // list contains empty elements
// convert myList to myArray
myArray=listToArray(myList,";",false,true); // Using includeEmptyFields=false
// Display array elements
WriteDump(myArray);
</cfscript>
<cfscript>
myList="ten;twenty;thirty;fort;fifty;sixty;;seventy;;;eighty"; // list contains empty elements
// convert myList to myArray
myArray=listToArray(myList,";",true,true); // Using includeEmptyFields=true
// Display array elements
WriteDump(myArray);
</cfscript>
Real-world use cases of the ListToArray function
CSV data processing for product imports
An e-commerce company receives daily product updates from suppliers in CSV format. Each product line contains categories, tags, and features that need to be processed individually for database storage and search indexing. How it helps:
- Converts CSV strings to structured arrays for systematic processing
- Each array element gets proper classification (category, subcategory, features)
- Individual features become searchable tags
- Validates data integrity during the conversion process
<cfscript>
writeOutput("<h2>📦 USE CASE 1: CSV Product Data Processing</h2>");
writeOutput("<h3>Business Context:</h3>");
writeOutput("<p>An e-commerce company receives daily product updates from suppliers in CSV format. Each product line contains categories, tags, and features that need to be processed individually for database storage and search indexing.</p>");
// Sample CSV product data from supplier
productCsvData = "Electronics,Laptops,Gaming Notebooks,High-Performance,RGB Lighting,SSD Storage,16GB RAM";
writeOutput("<h4>📥 Raw CSV Data:</h4>");
writeOutput("<p><code>" & productCsvData & "</code></p>");
// Convert CSV to array for processing
productArray = ListToArray(productCsvData, ",", false);
writeOutput("<h4>🔄 Processing Results:</h4>");
writeOutput("<table border='1' cellpadding='8'>");
writeOutput("<tr><th>Index</th><th>Product Attribute</th><th>Processing Action</th></tr>");
for (i = 1; i <= arrayLen(productArray); i++) {
attribute = trim(productArray[i]);
// Business logic for each attribute type
if (i == 1) {
action = "Primary Category Assignment";
category = attribute;
} else if (i == 2) {
action = "Subcategory Classification";
subcategory = attribute;
} else {
action = "Feature Tag for Search Index";
}
writeOutput("<tr>");
writeOutput("<td>" & i & "</td>");
writeOutput("<td>" & attribute & "</td>");
writeOutput("<td>" & action & "</td>");
writeOutput("</tr>");
}
writeOutput("</table>");
// Database insertion simulation
writeOutput("<h4>💾 Database Operations:</h4>");
writeOutput("<p><strong>Primary Category:</strong> " & (category ?: "N/A") & "</p>");
writeOutput("<p><strong>Subcategory:</strong> " & (subcategory ?: "N/A") & "</p>");
writeOutput("<p><strong>Feature Tags:</strong> " & arrayLen(productArray) - 2 & " tags indexed for search</p>");
writeOutput("<h4>💼 Business Value:</h4>");
writeOutput("<ul>");
writeOutput("<li>Automated processing of 1000+ products daily</li>");
writeOutput("<li>Consistent data structure for search optimization</li>");
writeOutput("<li>Reduced manual data entry errors by 95%</li>");
writeOutput("<li>Faster time-to-market for new products</li>");
writeOutput("</ul>");
writeOutput("<hr>");
</cfscript>
User permission and role management
A corporate CRM system serves 500+ employees across multiple departments with varying access requirements. User permissions are stored as comma-separated lists in the database to maintain flexibility while ensuring security compliance. How it works:
- Each permission becomes an array element for precise access management
- Empty array slots show deactivated permissions for compliance reporting
- Real-time permission evaluation without database restructuring
- Easy addition/removal of permissions without schema changes
<cfscript>
writeOutput("<h2>👥 USE CASE 2: User Permissions & Role Management</h2>");
writeOutput("<h3>Business Context:</h3>");
writeOutput("<p>A corporate CRM system stores user permissions as comma-separated lists in the database. When users log in, these permissions need to be converted to arrays for role-based access control throughout the application.</p>");
// Sample user permission data (includes empty elements for inactive roles)
userPermissions = "read_customers,write_customers,,read_reports,admin_users,,delete_records";
writeOutput("<h4>📥 Raw Permission String:</h4>");
writeOutput("<p><code>" & userPermissions & "</code></p>");
writeOutput("<p><em>Note: Empty elements represent deactivated permissions</em></p>");
// Process permissions excluding empty fields (inactive permissions)
activePermissions = ListToArray(userPermissions, ",", false);
writeOutput("<h4>✅ Active Permissions Processing:</h4>");
writeOutput("<p><strong>includeEmptyFields = false</strong></p>");
permissionCategories = {
"read": [],
"write": [],
"admin": [],
"delete": []
};
for (permission in activePermissions) {
cleanPermission = trim(permission);
// Categorize permissions by type
if (findNoCase("read_", cleanPermission)) {
arrayAppend(permissionCategories.read, cleanPermission);
} else if (findNoCase("write_", cleanPermission)) {
arrayAppend(permissionCategories.write, cleanPermission);
} else if (findNoCase("admin_", cleanPermission)) {
arrayAppend(permissionCategories.admin, cleanPermission);
} else if (findNoCase("delete_", cleanPermission)) {
arrayAppend(permissionCategories.delete, cleanPermission);
}
}
writeOutput("<table border='1' cellpadding='8'>");
writeOutput("<tr><th>Permission Level</th><th>Granted Permissions</th><th>Count</th></tr>");
for (level in permissionCategories) {
permissions = permissionCategories[level];
writeOutput("<tr>");
writeOutput("<td><strong>" & uCase(level) & "</strong></td>");
writeOutput("<td>" & (arrayLen(permissions) > 0 ? arrayToList(permissions, ", ") : "None") & "</td>");
writeOutput("<td>" & arrayLen(permissions) & "</td>");
writeOutput("</tr>");
}
writeOutput("</table>");
// Now process with empty fields to see all assigned slots
allPermissionSlots = ListToArray(userPermissions, ",", true);
writeOutput("<h4>📊 Permission Audit (including empty slots):</h4>");
writeOutput("<p><strong>includeEmptyFields = true</strong> - Shows all permission slots including deactivated ones</p>");
writeOutput("<table border='1' cellpadding='8'>");
// writeOutput("<tr><th>Slot #</th><th>Permission</th><th>Status</th></tr>");
for (i = 1; i <= arrayLen(allPermissionSlots); i++) {
permission = trim(allPermissionSlots[i]);
status = len(permission) > 0 ? "Active" : "Deactivated";
statusColor = len(permission) > 0 ? "green" : "red";
writeOutput("<tr>");
writeOutput("<td>" & i & "</td>");
writeOutput("<td>" & (len(permission) > 0 ? permission : "<em>Empty Slot</em>") & "</td>");
writeOutput("<td style='color: " & statusColor & ";'><strong>" & status & "</strong></td>");
writeOutput("</tr>");
}
writeOutput("</table>");
writeOutput("<h4>💼 Business Value:</h4>");
writeOutput("<ul>");
writeOutput("<li>Granular access control for 500+ enterprise users</li>");
writeOutput("<li>Easy permission auditing and compliance reporting</li>");
writeOutput("<li>Flexible role management without database schema changes</li>");
writeOutput("<li>Reduced security vulnerabilities through systematic access control</li>");
writeOutput("</ul>");
writeOutput("<hr>");
</cfscript>
Multi-language content processing
A global eLearning platform serves customers in 50+ countries, requiring content delivery in multiple languages. Course materials, descriptions, and metadata must be maintained efficiently while supporting rapid localization. How it helps:
- Single field contains all translations using multi-character delimiters
- Real-time content delivery based on user language preferences
- Content managers update one field instead of multiple database records
- Easy addition of new languages without database schema changes
<cfscript>
writeOutput("<h2>🌍 USE CASE 3: Multi-Language Content Processing</h2>");
writeOutput("<h3>Business Context:</h3>");
writeOutput("<p>A global e-learning platform stores course content in multiple languages separated by multi-character delimiters. This allows content managers to maintain translations in a single field while enabling easy separation for display.</p>");
// Course content with multi-language translations separated by special delimiter
courseContent = "Introduction to Programming||Introducción a la Programación||Einführung in die Programmierung||プログラミング入門||프로그래밍 소개";
writeOutput("<h4>📥 Multi-Language Content String:</h4>");
writeOutput("<p><code>" & courseContent & "</code></p>");
writeOutput("<p><em>Languages: English || Spanish || German || Japanese || Korean</em></p>");
// Process with multi-character delimiter
languageArray = ListToArray(courseContent, "||", false, true);
writeOutput("<h4>🔄 Language Processing Results:</h4>");
// Language codes mapping
languageCodes = ["EN", "ES", "DE", "JA", "KO"];
languageNames = ["English", "Spanish", "German", "Japanese", "Korean"];
writeOutput("<table border='1' cellpadding='8'>");
writeOutput("<tr><th>Language Code</th><th>Language</th><th>Translated Content</th><th>Character Count</th></tr>");
for (i = 1; i <= arrayLen(languageArray); i++) {
if (i <= arrayLen(languageCodes)) {
content = trim(languageArray[i]);
writeOutput("<tr>");
writeOutput("<td><strong>" & languageCodes[i] & "</strong></td>");
writeOutput("<td>" & languageNames[i] & "</td>");
writeOutput("<td>" & content & "</td>");
writeOutput("<td>" & len(content) & "</td>");
writeOutput("</tr>");
}
}
writeOutput("</table>");
// Content localization function
function getLocalizedContent(contentArray, userLanguage) {
languageMap = {
"en": 1,
"es": 2,
"de": 3,
"ja": 4,
"ko": 5
};
languageIndex = languageMap[lCase(userLanguage)] ?: 1;
if (languageIndex <= arrayLen(contentArray)) {
return trim(contentArray[languageIndex]);
}
return trim(contentArray[1]); // Fallback to English
}
// Demonstrate localization for different users
writeOutput("<h4>🎯 User Localization Examples:</h4>");
testUsers = [
{lang: "en", name: "John (USA)"},
{lang: "es", name: "María (Mexico)"},
{lang: "de", name: "Hans (Germany)"},
{lang: "ja", name: "田中 (Japan)"},
{lang: "ko", name: "김철수 (Korea)"}
];
writeOutput("<table border='1' cellpadding='8'>");
writeOutput("<tr><th>User</th><th>Preferred Language</th><th>Localized Content</th></tr>");
for (user in testUsers) {
localizedContent = getLocalizedContent(languageArray, user.lang);
writeOutput("<tr>");
writeOutput("<td>" & user.name & "</td>");
writeOutput("<td>" & uCase(user.lang) & "</td>");
writeOutput("<td>" & localizedContent & "</td>");
writeOutput("</tr>");
}
writeOutput("</table>");
</cfscript>
Survey response analysis
A market research company conducts customer satisfaction surveys for Fortune 500 clients. Multiple-choice questions with checkbox responses need sophisticated analysis to generate actionable business insights and strategic recommendations. How it helps:
- Converts checkbox responses to arrays for statistical processing
- Identifies most/least important features across customer segments
- Handles incomplete responses and empty selections gracefully
- Generates priority rankings and business recommendations
<cfscript>
writeOutput("<h2>📊 USE CASE 4: Survey Response Analysis</h2>");
writeOutput("<h3>Business Context:</h3>");
writeOutput("<p>A market research company collects customer feedback through online surveys. Multiple-choice questions with checkboxes are stored as comma-separated lists. Analytics need to process these responses to generate insights and reports.</p>");
// Sample survey responses for "Which features are most important to you?"
surveyResponses = [
"Price,Quality,Customer Service,Warranty",
"Quality,Design,Brand Reputation,Warranty,",
"Price,,Customer Service,Fast Delivery,Warranty",
"Quality,Design,Brand Reputation",
"Price,Quality,,Fast Delivery,"
];
writeOutput("<h4>📥 Raw Survey Data:</h4>");
writeOutput("<p><em>Question: Which features are most important to you? (Check all that apply)</em></p>");
featureCount = {};
totalResponses = arrayLen(surveyResponses);
writeOutput("<table border='1' cellpadding='8'>");
//writeOutput("<tr><th>Response #</th><th>Raw Data</th><th>Selected Features</th><th>Selection Count</th></tr>");
for (i = 1; i <= arrayLen(surveyResponses); i++) {
response = surveyResponses[i];
// Process response excluding empty fields (unchecked boxes)
selectedFeatures = ListToArray(response, ",", false);
writeOutput("<tr>");
writeOutput("<td>" & i & "</td>");
writeOutput("<td><code>" & response & "</code></td>");
writeOutput("<td>" & arrayToList(selectedFeatures, ", ") & "</td>");
writeOutput("<td>" & arrayLen(selectedFeatures) & "</td>");
writeOutput("</tr>");
// Count feature frequencies
for (feature in selectedFeatures) {
cleanFeature = trim(feature);
if (len(cleanFeature) > 0) {
if (!structKeyExists(featureCount, cleanFeature)) {
featureCount[cleanFeature] = 0;
}
featureCount[cleanFeature]++;
}
}
}
writeOutput("</table>");
// Generate analytics report
writeOutput("<h4>📈 Feature Popularity Analysis:</h4>");
// Sort features by popularity
featureStats = [];
for (feature in featureCount) {
count = featureCount[feature];
percentage = round((count / totalResponses) * 100);
arrayAppend(featureStats, {
feature: feature,
count: count,
percentage: percentage
});
}
// Sort by count (descending)
arraySort(featureStats, function(a, b) {
return b.count - a.count;
});
writeOutput("<table border='1' cellpadding='8'>");
writeOutput("<tr><th>Rank</th><th>Feature</th><th>Responses</th><th>Percentage</th><th>Priority Level</th></tr>");
for (i = 1; i <= arrayLen(featureStats); i++) {
stat = featureStats[i];
// Determine priority level
if (stat.percentage >= 80) {
priority = "Critical";
priorityColor = "red";
} else if (stat.percentage >= 60) {
priority = "High";
priorityColor = "orange";
} else if (stat.percentage >= 40) {
priority = "Medium";
priorityColor = "blue";
} else {
priority = "Low";
priorityColor = "gray";
}
writeOutput("<tr>");
writeOutput("<td>" & i & "</td>");
writeOutput("<td><strong>" & stat.feature & "</strong></td>");
writeOutput("<td>" & stat.count & " / " & totalResponses & "</td>");
writeOutput("<td>" & stat.percentage & "%</td>");
writeOutput("<td style='color: " & priorityColor & ";'><strong>" & priority & "</strong></td>");
writeOutput("</tr>");
}
writeOutput("</table>");
// Business recommendations
writeOutput("<h4>🎯 Business Recommendations:</h4>");
writeOutput("<ul>");
for (i = 1; i <= min(3, arrayLen(featureStats)); i++) {
stat = featureStats[i];
writeOutput("<li><strong>" & stat.feature & "</strong>: Top priority - mentioned by " & stat.percentage & "% of respondents</li>");
}
</cfscript>
