6 * Copyright (c) 1999-2001 The Squirrelmail Development Team
7 * Licensed under the GNU GPL. For full terms see the file COPYING.
9 * This contains functions that work with array manipulation. They
10 * will help sort, and do other types of things with arrays
15 function ary_sort($ary,$col, $dir = 1)
17 /* The globals are used because USORT determines what is passed to comp2 */
18 /* These should be $this->col and $this->dir in a class */
19 /* Would beat using globals */
20 if (!is_array($col)) {
23 $GLOBALS['col'] = $col; /* Column or Columns as an array */
30 /* Direction, a positive number for ascending a negative for descending */
31 $GLOBALS['dir'] = $dir;
33 usort($ary,'array_comp2');
37 function array_comp2($a,$b,$i = 0)
42 if ($a[$col[$i]] == $b[$col[$i]]) {
44 while ($i < $c && $r == 0) {
49 elseif ($a[$col[$i]] < $b[$col[$i]]) {
55 function removeElement($array, $element)
58 for ($i = 0;$i < count($array);$i++
) {
60 $newArray[$j] = $array[$i];
67 function array_cleave($array1, $column)
71 while ($key < count($array1)) {
72 array_push($array2, $array1[$key][$column]);