ListToArray

Converts a delimited list to an array

Method Signature

ListToArray(list=[string], delimiter=[string], includeEmptyFields=[boolean], multiCharacterDelimiter=[boolean])

Arguments

Argument
Type
Required
Description
Default

list

string

true

string list to filter entries from

delimiter

string

false

string the list delimiter

,

includeEmptyFields

boolean

false

boolean whether to include empty fields in the returned result

false

multiCharacterDelimiter

boolean

false

boolean whether the delimiter is multi-character

false

Examples

Simple example for listToArray function

Uses the listToArray() function to retrieve a list as an array

Run Example

list = "red,green,orange";
getArray = listToArray( list );
someJSON = JSONSerialize( getArray );
writeOutput( someJSON );

Result: ["red", "green", "orange"]

Example for listToArray function with delimiter

Uses the listToArray() function with a semicolon delimiter to retrieve a list as an array

Run Example

list = "boxlang;php;java;sql";
getArray = listToArray( list, ";" );
someJSON = JSONSerialize( getArray );
writeOutput( someJSON );

Result: ["boxlang", "php", "java", "sql"]

Example for listToArray function with includeEmptyFields

If includeEmptyFields is true, empty value add in array elements

Run Example

list = "boxlang;php;;java;sql";
getArray = listToArray( list, ";", true );
someJSON = JSONSerialize( getArray );
writeOutput( someJSON );

Result: ["boxlang", "php", " " , "java", "sql"]

Example for listToArray function with multiCharacterDelimiter

Uses the listToArray() function to retrieve a list as an array with multiCharacterDelimiter

Run Example

list = "boxlang,php,|test,java,|sql";
getArray = listToArray( list, ",|", false, true );
someJSON = JSONSerialize( getArray );
writeOutput( someJSON );

Result: ["boxlang,php", "test,java", "sql"]

Additional Examples

Run Example

list = "red,green,orange";
getArray = listToArray( list );
someJSON = JSONSerialize( getArray );
writeOutput( someJSON );

Run Example

list = "boxlang;php;java;sql";
getArray = listToArray( list, ";" );
someJSON = JSONSerialize( getArray );
writeOutput( someJSON );

Run Example

list = "boxlang;php;;java;sql";
getArray = listToArray( list, ";", true );
someJSON = JSONSerialize( getArray );
writeOutput( someJSON );

Run Example

list = "boxlang,php,|test,java,|sql";
getArray = listToArray( list, ",|", false, true );
someJSON = JSONSerialize( getArray );
writeOutput( someJSON );

Last updated

Was this helpful?