note 100496 deleted from function.array-slice by cmb

From: Date: Sun, 29 Dec 2019 12:30:21 +0000
Subject: note 100496 deleted from function.array-slice by cmb
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-213705@lists.php.net to get a copy of this message
Note Submitter: joel dot a dot villarreal at gmail dot com ---- An implementation of array_slice that do not resets the cursor. <?php function get_from_array($arr, $start, $length) { $sliced = array(); foreach ($arr as $k => $v) { if ($start <= $k && $k <= $start + $length - 1) { $sliced[] = $v; if (count($sliced) == $length) break; } } return $sliced; } ?> Cheers, Joel A. Villarreal Bertoldi

« previous php.notes (#213705) next »