I need a function that will return the last / first element of an N array.
For instance:
$data = array( '0','1','2','3','4','5','6','7','8','9','10' );
If
getItems( $data, '5', 'first' ); output: array( '0','1','2','3','4' )
If
getItems( $data, '2', 'last' ); output: array( '9','10' );
, if
getItems( $data, '11', 'first' ); or getItems( $data, '11', 'last' ); output: array( '0','1','2','3','4','5','6','7','8','9','10' );
Does such a function already exist. If not, what is the shortest way.
thanks