ArrayPrepend()
Inserts an array element at the beginning of an array and shifts the positions of the existing elements to make room.
ArrayPrepend( array=array, value=any, merge=boolean );
Returns: Boolean
| Argument | Description |
|---|---|
|
array
array,
required
|
edit
Name of an array |
|
value
any,
required
|
edit
value to prepend |
|
merge
boolean,
optional
|
edit
This argument only applies when the value is an array. If set to true prepend array elements individually to the source array. If false (default) the complete array is added as one element at the top, in the source array. |
Examples
editAdd an array item on to the front of an array
someArray = [3,2,1];
arrayPrepend(someArray, 4);
dump(someArray);
// member function
doctorWhoArray = ['Whittaker','Tennant','Baker'];
doctorWhoArray.prepend('Hurt');
dump(doctorWhoArray);
See also
- Arrays
- array.prepend()
- Search Issue Tracker open_in_new
- Search Lucee Test Cases open_in_new (good for further, detailed examples)