note 47170 deleted from function.array-slice by aidan
| From: | aidan@php.net | Date: | Fri, 05 Nov 2004 04:00:16 +0000 |
| Subject: | note 47170 deleted from function.array-slice by aidan | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-80122@lists.php.net to get a copy of this message | ||
Note Submitter: fankounter at libero dot it
----
// As "array_slice(array,offset,length,TRUE)" for PHP5.0.2
// array_slice() in PHP4 not preserve Numeric Keys.
// array_slice_PK() do it.
function array_slice_PK($__array,$__offset,$__length=FALSE)
{
settype($__array,"array");
settype($__offset,"integer");
settype($__length,(is_bool($__length))?"boolean":"integer");
for($__size=count($__array),$__count=0;
$__count<(($__offset>=0)?$__offset:$__size+$__offset);
$__count++)
{
reset($__array);
unset($__array[key($__array)]);
}
if($__length!==FALSE)
for($__size=count($__array),$__count=0;
$__count<(($__length>=0)?$__size-$__length:abs($__length));
$__count++)
{
end($__array);
unset($__array[key($__array)]);
}
return $__array;
}