note 124238 added to function.array-shift

From: Date: Thu, 26 Sep 2019 13:35:19 +0000
Subject: note 124238 added to function.array-shift
Groups: php.notes 
Request: Send a blank email to php-notes+get-212361@lists.php.net to get a copy of this message
// Ex. 1: signedShiftArray (['A', 'B', 'C', 'D'], 2) -> ['C', 'D', 'A', 'B'] // Ex. 2: signedShiftArray (['A', 'B', 'C', 'D'], -3) -> ['B', 'C', 'D', 'A'] // Ex. 3: signedShiftArray (['A', 'B', 'C', 'D'], -7) -> ['B', 'C', 'D', 'A'] function signedShiftArray ($aItems, $aOffset) { if (empty ($aItems)) return []; else if (empty ($aOffset)) return $aItems; else { $t= count ($aItems); $n= $aOffset % $t; $m= $aOffset > 0 ? $n : $t + $aOffset; return array_merge (array_slice ($aItems, $n), array_slice ($aItems, 0, $m)); } } ---- Server IP: 208.43.231.9 Probable Submitter: 82.199.157.54 (proxied: 201.54.221.209) ---- Manual Page -- http://php.net/manual/en/function.array-shift.php Edit -- https://master.php.net/note/edit/124238 Del: integrated -- https://master.php.net/note/delete/124238/integrated Del: useless -- https://master.php.net/note/delete/124238/useless Del: bad code -- https://master.php.net/note/delete/124238/bad+code Del: spam -- https://master.php.net/note/delete/124238/spam Del: non-english -- https://master.php.net/note/delete/124238/non-english Del: in docs -- https://master.php.net/note/delete/124238/in+docs Del: other reasons-- https://master.php.net/note/delete/124238 Reject -- https://master.php.net/note/reject/124238 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#212361) next »