[ Index ]
 

Code source de eGroupWare 1.2.106-2

Accédez au Source d'autres logiciels libresSoutenez Angelica Josefina !

title

Body

[fermer]

/phpgwapi/inc/ -> class.arrayfunctions.inc.php (source)

   1  <?php
   2      /*******************************************************************\
   3      * eGroupWare API - Arrayfunctions                                   *
   4      * Written by Lars Kneschke <lkneschke@phpgw.de>                     *
   5      * Copyright (C) 2002, 2003 Lars Kneschke                            *
   6      * ----------------------------------------------------------------- *
   7      * This library is part of the eGroupWare API                        *
   8      * ----------------------------------------------------------------- *
   9      * This program is free software; you can redistribute it and/or     *
  10      * modify it under the terms of the GNU General Public License as    *
  11      * published by the Free Software Foundation; either version 2 of    *
  12      * the License, or (at your option) any later version.               *
  13      *                                                                   *
  14      * This program is distributed in the hope that it will be useful,   *
  15      * but WITHOUT ANY WARRANTY; without even the implied warranty of    *
  16      * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU  *
  17      * General Public License for more details.                          *
  18      *                                                                   *
  19      * You should have received a copy of the GNU General Public License *
  20      * along with this program; if not, write to the Free Software       *
  21      * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.         *
  22      \*******************************************************************/
  23      /* $Id: class.arrayfunctions.inc.php 16311 2004-08-09 13:46:03Z reinerj $ */
  24  
  25      class arrayfunctions
  26      {
  27  		function arrayfunctions($vars='')
  28          {
  29          }
  30  
  31          /*
  32          * arfsort() - (AR)ray (F)ield Sort.
  33          * Sort a multi-dimensional array according
  34          * to a list of fields.
  35          * @param $a The array to sort
  36          * @param $fl Field list (in order of importance)
  37          */
  38          
  39  		function arfsort( $a, $fl, $_sort='ASC' )
  40          {
  41              $GLOBALS['__ARFSORT_LIST__'] = $fl;
  42              
  43              $this->sort=$_sort;
  44  
  45              if (is_array($a))
  46              {
  47                  usort( $a, array($this,'arfsort_func') );
  48                  return $a;
  49              }
  50              return False;
  51          }
  52  
  53          /*
  54          * Internal sorting function for arfsort()
  55          */
  56  		function arfsort_func( $a, $b )
  57          {
  58              foreach( $GLOBALS['__ARFSORT_LIST__'] as $f )
  59              {
  60                  if($this->sort == 'ASC')
  61                  {
  62                      $strc = strcmp( $a[$f], $b[$f] );
  63                  }
  64                  else
  65                  {
  66                      $strc = strcmp( $b[$f], $a[$f] );
  67                  }
  68                  if ( $strc != 0 )
  69                  {
  70                      return $strc;
  71                  }
  72              }
  73              return 0;
  74          }
  75  
  76      } // end class arrayfunctions
  77  ?>


Généré le : Sun Feb 25 17:20:01 2007 par Balluche grâce à PHPXref 0.7