[array->remove] removes an item from the array.
Accepts a single integer parameter identifying the position of the item to be removed. Defaults to the last item in the array. An optional length parameter may be added which specifies how many items are to be removed from the array beginning with the one specified (ie. array->remove(2,1) is the same as array->remove(2). )
The first element in an array is at position 1. An error is returned if the position specified is beyond the size of the array or if the sum of the number of elements to be removed and the position of the starting element is more than the size of the array.
Note: The specified element(s) in the array is(are) removed and the positions of all elements in the array above the position are adjusted down as required.
array->remove() array->remove( element_position ) array->remove( element_position, number_of_elements )
Use the [array->remove] method.
The following example removes the third element, Tue, from an array of the days of the week. The remainder of the array is output.
var( DaysOfWeek = array('Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat') ) $DaysOfWeek->remove(3) $DaysOfWeek
array(Sun, Mon, Wed, Thu, Fri, Sat)
This example removes the middle three days (Tue, Wed, Thu) from an array of the days of the week.
var( DaysOfWeek = array('Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat') ) $DaysOfWeek->remove(3,3) $DaysOfWeek
array(Sun, Mon, 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.