Skip to content

Instantly share code, notes, and snippets.

@dotsonjb14
Last active December 18, 2015 23:39
Show Gist options
  • Save dotsonjb14/5863362 to your computer and use it in GitHub Desktop.
Save dotsonjb14/5863362 to your computer and use it in GitHub Desktop.
<?php
/*
$pages is an array of assoc arrays containing all of the menu items
$id is the page to be moved
$matches[2] is the direction
*/
$len = count($pages);
for ($i=0; $i < $len; $i++)
{
if($pages[$i]["ID"] == $id)
{
if($matches[2] == "up")
{
$tmp = $pages[$i];
$nkey = (int)$i-1;
$pages[$i] = $pages[$nkey];
$pages[$nkey] = $tmp;
}
else
{
$tmp = $pages[$i];
$nkey = (int)$i+1;
$pages[$i] = $pages[$nkey];
$pages[$nkey] = $tmp;
}
break;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment