Adds an element or an object to the end of an array, then returns the size of the modified array.
arrayPush(array, value)
→ returns numeric
array.push(value)
This is the full function version of arrayPush to push a value onto the end of the array.
arr=[1,2,3];
arrayPush(array=arr,value=42);
writeOutput('This array has ' & arrayLen(arr) & ' elements.');
Expected Result: This array has 4 elements.
Using the member function. This version also works in ACF2018.
arr=[1,2,3];
al=arr.push(42);
writeOutput('This array has ' & al & ' elements.');
Expected Result: This array has 4 elements.
This demonstrates pushing an object onto an array.
arr=[ [1],['two'],[{a:3}]];
al=arr.push([42]);
writeOutput('This array has ' & al & ' elements.');
Expected Result: This array has 4 elements.
Signup for cfbreak
to stay updated on the latest news from the ColdFusion / CFML community. One email, every friday.