Deletes the first element in an array that matches the value of value
.
The search is case-sensitive.
Returns true
if the element was found and removed.
The array will be resized, so that the deleted element doesn't leave a gap.
arrayDelete(array, value)
→ returns boolean
someArray.delete(value)
one
one
all
Uses the arrayDelete function to delete an element from an array
arr = ['apple', 'orange', 'pear', 'apple'];
arrayDelete(arr, 'apple');
writeDump(arr);
Expected Result: ['orange','pear','apple']
CF 11+ Lucee 4.5+ Invoking the delete function on an array is the same as running arrayDelete.
arr = ['apple', 'orange', 'pear', 'apple'];
arr.delete('apple');
writeDump(arr);
Expected Result: ['orange','pear','apple']
Lucee 4.5+ Use scope to remove one or all occurrences of the value
arr = ['apple', 'orange', 'pear', 'apple'];
arr.delete('apple', 'all');
writeDump(arr);
Expected Result: ['orange','pear']
Signup for cfbreak
to stay updated on the latest news from the ColdFusion / CFML community. One email, every friday.