note 73882 added to function.array-slice
| From: | php-general at lists dot php dot net | Date: | Wed, 14 Mar 2007 16:09:30 +0000 |
| Subject: | note 73882 added to function.array-slice | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-124438@lists.php.net to get a copy of this message | ||
I noticed that some other people made supportive functions for maintaining numeric keys for PHP
versions less than 5.0.2. So here is my version of it.
<?php
//Slice an array but keep numeric keys
function narray_slice($array, $offset, $length) {
//Check if this version already supports it
if (str_replace('.', '', PHP_VERSION) >= 502)
return array_slice($array, $offset, $length, true);
foreach ($array as $key => $value) {
if ($a >= $offset && $a - $offset <= $length)
$output_array[$key] = $value;
$a++;
}
return $output_array;
}
?>
----
Server IP: 66.207.199.35
Probable Submitter: 24.89.250.75
----
Manual Page -- http://www.php.net/manual/en/function.array-slice.php
Edit -- https://master.php.net/note/edit/73882
Del: integrated -- https://master.php.net/note/delete/73882/integrated
Del: useless -- https://master.php.net/note/delete/73882/useless
Del: bad code -- https://master.php.net/note/delete/73882/bad+code
Del: spam -- https://master.php.net/note/delete/73882/spam
Del: non-english -- https://master.php.net/note/delete/73882/non-english
Del: in docs -- https://master.php.net/note/delete/73882/in+docs
Del: other reasons-- https://master.php.net/note/delete/73882
Reject -- https://master.php.net/note/reject/73882
Search -- https://master.php.net/manage/user-notes.php