note 119239 added to function.array-splice

From: Date: Mon, 25 Apr 2016 14:45:44 +0000
Subject: note 119239 added to function.array-splice
Groups: php.notes 
Request: Send a blank email to php-notes+get-205325@lists.php.net to get a copy of this message
array_splice with preserve keys <?php function array_splice_preserve_keys(&$array, $from, $length = null) { $result = array_slice($array, $from, $length, true); $array = array_slice($array, $from + $length, null, true); return $result; } ?> Example: <?php $array = [ 1 => 'a', 2 => 'b', 26 => 'z' ]; var_dump(array_splice_preserve_keys($array, 0, 1), $array); /** * array(1) { * [1]=> * string(1) "a" * } * array(2) { * [2]=> * string(1) "b" * [26]=> * string(1) "z" * } */ ?> ---- Server IP: 72.52.91.14 Probable Submitter: 178.236.241.208 ---- Manual Page -- http://php.net/manual/en/function.array-splice.php Edit -- https://master.php.net/note/edit/119239 Del: integrated -- https://master.php.net/note/delete/119239/integrated Del: useless -- https://master.php.net/note/delete/119239/useless Del: bad code -- https://master.php.net/note/delete/119239/bad+code Del: spam -- https://master.php.net/note/delete/119239/spam Del: non-english -- https://master.php.net/note/delete/119239/non-english Del: in docs -- https://master.php.net/note/delete/119239/in+docs Del: other reasons-- https://master.php.net/note/delete/119239 Reject -- https://master.php.net/note/reject/119239 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#205325) next »