Core Function Remove
From Sputnik Wiki
Remove( <array>, <start-id>, <end-id> )
Contents |
Description
Delete items from an array starting at a given location and stopping at a given location
Parameters
array
The array to use.
start-id
Location to start deleting from.
end-id
Optional; Location to stop deleting at.
If this parameter is not given it then only the item at the start-id will be deleted and nothing else.
Return Value
Success - Returns the amount of objects removed.
Failure - Returns 0.
Remarks
None
Example
// Delete a single item
$array = array ( "One", "Two", "Three", "Four", "Five" ); Remove($array, 1); //unset($array[1]); // Alternative method $i = 0; Foreach ( $array as $i ) { println("Element ($i) is: " . $i); $i++; }
// Delete a range
$array = array ( "One", "Two", "Three", "Four", "Five" ); Remove($array, 1, 2); $i = 0; Foreach ( $array as $i ) { println("Element ($i) is: " . $i); $i++; }