Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /**
- * Move array position
- *
- * @return array
- */
- function array_splice_assoc(&$input, $offset, $length, $replacement) {
- $replacement = (array) $replacement;
- $key_indices = array_flip(array_keys($input));
- if (isset($input[$offset]) && is_string($offset)) {
- $offset = $key_indices[$offset];
- }
- if (isset($input[$length]) && is_string($length)) {
- $length = $key_indices[$length] - $offset;
- }
- $input = array_slice($input, 0, $offset, TRUE) + $replacement + array_slice($input, $offset + $length, NULL, TRUE);
- }
- function cpr_move_positin_element($which, $where, $array)
- {
- $tmpWhich = $which;
- $j=0;
- $keys = array_keys($array);
- for($i=0;$i<count($array);$i++)
- {
- if($keys[$i]==$tmpWhich)
- $tmpWhich = $j;
- else
- $j++;
- }
- $tmp = array_splice($array, $tmpWhich, 1);
- array_splice_assoc($array, $where, 0, $tmp);
- return $array;
- }
Add Comment
Please, Sign In to add comment