From: maxious Date: Fri, 11 Mar 2011 10:38:07 +0000 Subject: Nearby routes and routes by suburb X-Git-Url: https://maxious.lambdacomplex.org/git/?p=busui.git&a=commitdiff&h=6dbec5c1dac28b1f2b7845aee89b7ee52acd3f98 --- Nearby routes and routes by suburb --- --- a/common.inc.php +++ b/common.inc.php @@ -150,5 +150,33 @@ { return str_replace(")", "", str_replace("(", "
", $input)); } + +function sksort(&$array, $subkey="id", $sort_ascending=false) { + + if (count($array)) + $temp_array[key($array)] = array_shift($array); + + foreach($array as $key => $val){ + $offset = 0; + $found = false; + foreach($temp_array as $tmp_key => $tmp_val) + { + if(!$found and strtolower($val[$subkey]) > strtolower($tmp_val[$subkey])) + { + $temp_array = array_merge( (array)array_slice($temp_array,0,$offset), + array($key => $val), + array_slice($temp_array,$offset) + ); + $found = true; + } + $offset++; + } + if(!$found) $temp_array = array_merge($temp_array, array($key => $val)); + } + + if ($sort_ascending) $array = array_reverse($temp_array); + + else $array = $temp_array; +} ?> --- a/routeList.php +++ b/routeList.php @@ -1,7 +1,8 @@ '; -echo '