note 98028 added to function.array-slice

From: Date: Fri, 21 May 2010 13:44:20 +0000
Subject: note 98028 added to function.array-slice
Groups: php.notes 
Request: Send a blank email to php-notes+get-169490@lists.php.net to get a copy of this message
Updated version of narray_slice function below, syntax-compatible with php 4 and php 5 servers. It also works for text-index arrays function narray_slice($array, $offset, $length, $preserve_keys = false) { //Check if this version already supports it if (version_compare(PHP_VERSION, '5.0.2', '>=')){ return array_slice($array, $offset, $length, $preserve_keys); } else if ($preserve_keys == false) { return array_slice($array, $offset, $length); } $a = 0; foreach ($array as $key => $value) { if ($a >= $offset && $a - $offset < $length) $output_array[$key] = $value; $a++; } return $output_array; } ---- Server IP: 89.31.146.176 Probable Submitter: 193.252.58.53 ---- Manual Page -- http://www.php.net/manual/en/function.array-slice.php Edit -- https://master.php.net/note/edit/98028 Del: integrated -- https://master.php.net/note/delete/98028/integrated Del: useless -- https://master.php.net/note/delete/98028/useless Del: bad code -- https://master.php.net/note/delete/98028/bad+code Del: spam -- https://master.php.net/note/delete/98028/spam Del: non-english -- https://master.php.net/note/delete/98028/non-english Del: in docs -- https://master.php.net/note/delete/98028/in+docs Del: other reasons-- https://master.php.net/note/delete/98028 Reject -- https://master.php.net/note/reject/98028 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#169490) next »