Skip to content

Instantly share code, notes, and snippets.

<cfset test = "">
<cfdump var="#DateFormat(test, "dd.mm.yyyy")#">
<cfscript>
myStruct = {};
myStruct[ 1 ] = { "iso" : "de", "dir" : true, "label" : "Englisch" };
myStruct[ 2 ] = { "iso" : "de", "dir" : true, "label" : "Deutsch" };
myStruct[ 3 ] = { "iso" : "de", "dir" : true, "label" : "Französische" };
result = SerializeJSON( myStruct );
writeDump( result );
</cfscript>
<cfscript>
myStruct = {};
myStruct[ 1 ] = { "iso" : "de", "dir" : true, "label" : "Englisch" };
myStruct[ 2 ] = { "iso" : "de", "dir" : true, "label" : "Deutsch" };
myStruct[ 3 ] = { "iso" : "de", "dir" : true, "label" : "Französische" };
result = SerializeJSON( myStruct );
writeDump( result );
</cfscript>
<cfscript>
xmlObj = xmlParse( '<Ortus><Products></Products></Ortus>' );
products = [ "BoxLang", "CommandBox" ];
root = xmlObj.xmlRoot.Products.xmlChildren;
for( i = 1; i <= products.len(); i++ ){
product = xmlElemNew( xmlObj, "Product" );
product.xmlText = products[ i ];
// Below will pass when uncommented
// xmlObj.xmlRoot.Products.xmlChildren.append( product );
xmlObj.xmlRoot.Products.xmlChildren[ i ] = product;
<cfset test = xmlNew()>
<cfdump var="#test#">
<cfset myArray = ArrayNew(2)>
<cfset ArrayAppend(myArray, "Apple")>
<cfset ArrayAppend(myArray, "Banana")>
<cfoutput>
<cfloop from="1" to="#ArrayLen(myArray)#" index="i">
#myArray[i]#<br>
</cfloop>
</cfoutput>
<cfoutput>
<cfset combineRatings[3] = 1;
]>
<cfloop array="#combineRatings#" index="ratingArray">
</cfloop>
<cfdump var = "#combineratings#">
<cfset arr = ";ROOF;1266;;Roof;;;INACTIVE">
<cfset EMPTY =''>
<!--- Manually replace semicolons to ensure each semicolon creates a split point, including empty values --->
<cfset arr = replace(arr, ";", "#EMPTY#", "ALL")>
<!--- Now split by the placeholder #EMPTY# to keep empty values --->
<cfset arrList = listToArray(arr, "#EMPTY#")>
<!--- Output the array length and the values --->
<cfoutput>
<cfset arr = ";ROOF;1266;;Roof;;;INACTIVE">
<!--- Manually replace semicolons to ensure each semicolon creates a split point, including empty values --->
<cfset arr = replace(arr, ";", "EMPTY", "ALL")>
<!--- Now split by the placeholder #EMPTY# to keep empty values --->
<cfset arrList = listToArray(arr, "#EMPTY#")>
<!--- Output the array length and the values --->
<cfoutput>
<cfset arr = ";ROOF;1266;;Roof;;;INACTIVE">
<cfset Empty = 'empty'>
<!--- Replace semicolons with a unique placeholder to handle empty values correctly --->
<cfset arr = replace(arr, ";", "#EMPTY#", "ALL")>
<!--- Split the string by the placeholder instead of semicolons --->
<cfset arrList = listToArray(arr, "EMPTY")>
<!--- Output the array length (should now be 8) --->
<cfoutput>