Skip to content

Instantly share code, notes, and snippets.

@nexocentric
Created November 15, 2013 07:52
Show Gist options
  • Save nexocentric/7480690 to your computer and use it in GitHub Desktop.
Save nexocentric/7480690 to your computer and use it in GitHub Desktop.
function down($array,$element) {
if(count($array)-1 > $element) {
$newArray = array_slice($array,0,$element,true);
$newArray[] = $array[$element+1];
$newArray[] = $array[$element];
$newArray += array_slice(
$array,
$element+2,
count($array),
true
);
return($newArray);
} else {
return $array;
}
}
function up($array,$element) {
if( $element > 0 and $element < count($array) ) {
$newArray = array_slice($array,0,($element-1),true);
$newArray[] = $array[$element];
$newArray[] = $array[$element-1];
$newArray += array_slice(
$array,
($element+1),
count($array),
true
);
return($newArray);
} else {
return $array;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment