note 18544 modified in function.array-slice by vrana
| From: | vrana@php.net | Date: | Tue, 17 Aug 2004 14:49:33 +0000 |
| Subject: | note 18544 modified in function.array-slice by vrana | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-79818@lists.php.net to get a copy of this message | ||
The same thing, written by a maladroit :)
<?php
function array_slice2( $array, $offset, $length = 0 )
{
if( $offset < 0 )
$offset = sizeof( $array ) + $offset;
$length = ( !$length ? sizeof( $array ) : ( $length < 0 ? sizeof( $array ) - $length : $length
+ $offset ) );
for( $i = $offset; $i < $length; $i++ )
$tmp[] = $array[$i];
return $tmp;
}
?>
--was--
The same thing, written by a maladroit :)
function array_slice2( $array, $offset, $length = 0 )
{
if( $offset < 0 )
$offset = sizeof( $array ) + $offset;
$length = ( !$length ? sizeof( $array ) : ( $length < 0 ? sizeof( $array ) - $length : $length
+ $offset ) );
for( $i = $offset; $i < $length; $i++ )
$tmp[] = $array[$i];
return $tmp;
}
http://php.net/manual/en/function.array-slice.php