ArrayInsertAt()
Inserts a value at the specified position in the array. If the element is inserted before the end of the array, Lucee shifts the positions of all elements with a higher index to make room.
ArrayInsertAt( array=array, position=number, value=any );
Returns: Boolean
Examples
Insert item into an array at a given position within the array length
fruitArray = ['apple', 'kiwi', 'banana', 'orange', 'mango', 'kiwi'];
arrayInsertAt(fruitArray,3,'new inserted item');
dump(fruitArray);
// member function
fruitArray.insertAt(3,'member added item');
dump(fruitArray);
See also
- Arrays
- array.insertAt()
- Search Issue Tracker
- Search Lucee Test Cases (good for further, detailed examples)