[array->insert()] inserts a value into the array.
Accepts a single parameter which is the value to be inserted and an optional integer parameter identifying the position of the location where the value should be inserted. Defaults to inserting the parameter at the end of the array. Returns no value.
The first element in an array is at position 1.
Note: This method will not replace an item in the array. Instead, it will insert the new item and increment the position of all the existing items that follow.
array->insert('value')
array->insert('value', position)
Use the [array->insert] method.
The following example starts with a partial array of the days of the week, then inserts 'Sun' as the first element and 'Sat' as the last element of the array.
Code
var(DaysOfWeek = array('Mon','Tue','Wed','Thu','Fri'))
$DaysOfWeek->insert('Sun', 1)
$DaysOfWeek->insert('Sat')
//output updated array
$DaysOfWeek
Result
array(Sun, Mon, Tue, Wed, Thu, Fri, Sat)
Please note that periodically LassoSoft will go through the notes and may incorporate information from them into the documentation. Any submission here gives LassoSoft a non-exclusive license and will be made available in various formats to the Lasso community.
©LassoSoft Inc 2015 | Web Development by Treefrog Inc | Privacy | Legal terms and Shipping | Contact LassoSoft
Recent Comments