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 /*****************************************************************/
16 /*** THIS FILE NEEDS TO HAVE ITS FORMATTING FIXED!!! ***/
17 /*** PLEASE DO SO AND REMOVE THIS COMMENT SECTION. ***/
18 /*** + Base level indent should begin at left margin, as ***/
19 /*** the first line of the function definition below. ***/
20 /*** + All identation should consist of four space blocks ***/
21 /*** + Tab characters are evil. ***/
22 /*** + all comments should use "slash-star ... star-slash" ***/
23 /*** style -- no pound characters, no slash-slash style ***/
24 /*** + FLOW CONTROL STATEMENTS (if, while, etc) SHOULD ***/
25 /*** ALWAYS USE { AND } CHARACTERS!!! ***/
26 /*** + Please use ' instead of ", when possible. Note " ***/
27 /*** should always be used in _( ) function calls. ***/
28 /*** Thank you for your help making the SM code more readable. ***/
29 /*****************************************************************/
31 function ary_sort($ary,$col, $dir = 1){
32 // The globals are used because USORT determines what is passed to comp2
33 // These should be $this->col and $this->dir in a class
34 // Would beat using globals
38 $GLOBALS['col'] = $col; // Column or Columns as an array
43 $GLOBALS['dir'] = $dir; // Direction, a positive number for ascending a negative for descending
45 usort($ary,'array_comp2');
49 function array_comp2($a,$b,$i = 0) {
53 if ($a[$col[$i]] == $b[$col[$i]]){
55 while($i < $c && $r == 0){
59 } elseif($a[$col[$i]] < $b[$col[$i]]){
65 function removeElement($array, $element) {
67 for ($i = 0;$i < count($array);$i++
)
69 $newArray[$j] = $array[$i];
76 function array_cleave($array1, $column)
80 while ($key < count($array1)) {
81 array_push($array2, $array1[$key][$column]);