[ Index ]
 

Code source de Cr@wltr@ck 2.2.1

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

title

Body

[fermer]

/graphs/artichow/php5/ -> common.php (source)

   1  <?php
   2  /*
   3   * This work is hereby released into the Public Domain.
   4   * To view a copy of the public domain dedication,
   5   * visit http://creativecommons.org/licenses/publicdomain/ or send a letter to
   6   * Creative Commons, 559 Nathan Abbott Way, Stanford, California 94305, USA.
   7   *
   8   */
   9  
  10  /*
  11   * Get the minimum of an array and ignore non numeric values
  12   */
  13  function array_min($array) {
  14  
  15      if(is_array($array) and count($array) > 0) {
  16      
  17          do {
  18              $min = array_pop($array);
  19              if(is_numeric($min === FALSE)) {
  20                  $min = NULL;
  21              }
  22          } while(count($array) > 0 and $min === NULL);
  23          
  24          if($min !== NULL) {
  25              $min = (float)$min;
  26          }
  27          
  28          foreach($array as $value) {
  29              if(is_numeric($value) and (float)$value < $min) {
  30                  $min = (float)$value;
  31              }
  32          }
  33          
  34          return $min;
  35      
  36      }
  37      
  38      return NULL;
  39  
  40  }
  41  
  42  /*
  43   * Get the maximum of an array and ignore non numeric values
  44   */
  45  function array_max($array) {
  46  
  47      if(is_array($array) and count($array) > 0) {
  48      
  49          do {
  50              $max = array_pop($array);
  51              if(is_numeric($max === FALSE)) {
  52                  $max = NULL;
  53              }
  54          } while(count($array) > 0 and $max === NULL);
  55          
  56          if($max !== NULL) {
  57              $max = (float)$max;
  58          }
  59          
  60          foreach($array as $value) {
  61              if(is_numeric($value) and (float)$value > $max) {
  62                  $max = (float)$value;
  63              }
  64          }
  65          
  66          return $max;
  67      
  68      }
  69      
  70      return NULL;
  71  
  72  }
  73  /*
  74   * Define file_put_contents() if needed
  75   */
  76  if(function_exists('file_put_contents') === FALSE) {
  77  
  78  	function file_put_contents($file, $content) {
  79          $fp = fopen($file, 'w');
  80          if($fp) {
  81              fwrite($fp, $content);
  82              fclose($fp);
  83          }
  84      }
  85      
  86  }
  87  
  88  /*
  89   * Change error handler
  90   */
  91  set_error_handler('errorHandlerArtichow');
  92  
  93  function errorHandlerArtichow($level, $message, $file, $line) {
  94      awImage::drawError($message.' in '.$file.' on line '.$line.'.');
  95  }
  96  ?>


Généré le : Thu Sep 6 14:14:11 2007 par Balluche grâce à PHPXref 0.7