Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PHP

php move in array

$array = [
    0 => 'a', 
    1 => 'c', 
    2 => 'd', 
    3 => 'b', 
    4 => 'e',
];

function moveElement(&$array, $a, $b) {
    $out = array_splice($array, $a, 1);
    array_splice($array, $b, 0, $out);
}

moveElement($array, 3, 1);
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #php #move #array
ADD COMMENT
Topic
Name
6+9 =