Created
November 15, 2013 07:52
-
-
Save nexocentric/7480690 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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