Skip to content

Instantly share code, notes, and snippets.

@samsonasik
Created January 15, 2013 19:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save samsonasik/4541063 to your computer and use it in GitHub Desktop.
Save samsonasik/4541063 to your computer and use it in GitHub Desktop.
function sortingAssoc($array, $sortby = "id",$sortir="asc")
{
$temp = array();
foreach($array as $key=>$row)
{
$temp[$key] = $row[$sortby];
}
if ($sortir=="asc") sort($temp); else rsort($temp);
$loop = 0;
foreach($temp as $key=>$row)
{
foreach($array as $keydata=>$rowdata)
{
if (!empty($temp[$loop])){
if ($temp[$loop]==$rowdata[$sortby]){
$temp[$loop] = $rowdata;
$loop++;
}
}
}
}
return $temp;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment