note 111421 added to function.array-slice
| From: | lenny dot nilsson at aftonbladet dot se | Date: | Mon, 18 Feb 2013 18:59:10 +0000 |
| Subject: | note 111421 added to function.array-slice | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-193674@lists.php.net to get a copy of this message | ||
//Rotate an associative array to start with a specific key
function rotate_array($array, $key) {
$keys = array_keys($array);
$values = array_values($array);
$offset = array_search($key, $keys);
$keys = array_merge(array_splice($keys, $offset), $keys);
$values = array_merge(array_splice($values, $offset), $values);
return array_combine($keys, $values);
}
----
Server IP: 69.147.83.199
Probable Submitter: 144.63.247.10
----
Manual Page -- http://php.net/manual/en/function.array-slice.php
Edit -- https://master.php.net/note/edit/111421
Del: integrated -- https://master.php.net/note/delete/111421/integrated
Del: useless -- https://master.php.net/note/delete/111421/useless
Del: bad code -- https://master.php.net/note/delete/111421/bad+code
Del: spam -- https://master.php.net/note/delete/111421/spam
Del: non-english -- https://master.php.net/note/delete/111421/non-english
Del: in docs -- https://master.php.net/note/delete/111421/in+docs
Del: other reasons-- https://master.php.net/note/delete/111421
Reject -- https://master.php.net/note/reject/111421
Search -- https://master.php.net/manage/user-notes.php