home *** CD-ROM | disk | FTP | other *** search
/ H4CK3R 4 / hacker04 / 04_HACK04.ISO / src / PHP / php.exe / Case.php < prev    next >
Encoding:
PHP Script  |  2001-07-02  |  872 b   |  24 lines

  1.     //**************************************
  2.     //     
  3.     // Name: Case insensitive alphabetical a
  4.     //     rray sorter
  5.     // Description:This function is to be us
  6.     //     ed with phps' built in usort(). It will 
  7.     //     sort an array alphabetically and case in
  8.     //     sensitively, something I found the norma
  9.     //     l sort() function didn't do. An example 
  10.     //     of usage: usort($array, 'isort'); Natura
  11.     //     lly the function should be included or d
  12.     //     efined in your code. By Richard Heyes.
  13.     // By: PHP Code Exchange
  14.     //**************************************
  15.     //     
  16.     
  17.     <?php
  18.     function isort($a,$b){
  19.     if(ord(substr(strtolower($a),0,1)) == ord(substr(strtolower($b),0,1))) return 0;
  20.     return (ord(substr(strtolower($a),0,1)) < ord(substr(strtolower($b),0,1))) ? -1 : 1;
  21.     }
  22.     ?>
  23.  
  24.