5 ** This contains functions that work with array manipulation. They
6 ** will help sort, and do other types of things with arrays
12 if (defined ('array_php'))
14 define ('array_php', true);
16 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
23 $GLOBALS['col'] = $col; // Column or Columns as an array
28 $GLOBALS['dir'] = $dir; // Direction, a positive number for ascending a negative for descending
30 usort($ary,'array_comp2');
34 function array_comp2($a,$b,$i = 0) {
38 if ($a[$col[$i]] == $b[$col[$i]]){
40 while($i < $c && $r == 0){
44 } elseif($a[$col[$i]] < $b[$col[$i]]){
50 function removeElement($array, $element) {
52 for ($i = 0;$i < count($array);$i++
)
54 $newArray[$j] = $array[$i];
61 function array_cleave($array1, $column)
65 while ($key < count($array1)) {
66 array_push($array2, $array1[$key][$column]);