/[cvs]/nfo/php/libs/org.netfrag.flib/utils/helper.php
ViewVC logotype

Diff of /nfo/php/libs/org.netfrag.flib/utils/helper.php

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.3 by joko, Wed Dec 11 01:00:22 2002 UTC revision 1.4 by jonen, Sun Dec 22 13:29:54 2002 UTC
# Line 3  Line 3 
3  //    $Id$  //    $Id$
4  //    -----------------------------------------------------------------------------  //    -----------------------------------------------------------------------------
5  //    $Log$  //    $Log$
6    //    Revision 1.4  2002/12/22 13:29:54  jonen
7    //    + added number format helper functions:
8    //      + number_format_locale()
9    //      + is_amount()
10    //
11  //    Revision 1.3  2002/12/11 01:00:22  joko  //    Revision 1.3  2002/12/11 01:00:22  joko
12  //    + renamed function 'sai' to 'array_init'  //    + renamed function 'sai' to 'array_init'
13  //  //
# Line 67  function array_init(&$var, $clear = 0) { Line 72  function array_init(&$var, $clear = 0) {
72    
73  // format functions  // format functions
74  function isvalidemailaddress($mail) {  function isvalidemailaddress($mail) {
75      // TODO: review for regex process load
76    //return ((($string = trim($string)) != '') && (($atpos = strpos($string, '@' , 1)) > 1) && (($rdotpos = strrpos($string, '.')) > ($atpos + 2)) && (strlen($string) > $rdotpos + 2));    //return ((($string = trim($string)) != '') && (($atpos = strpos($string, '@' , 1)) > 1) && (($rdotpos = strrpos($string, '.')) > ($atpos + 2)) && (strlen($string) > $rdotpos + 2));
77    if( !eregi("^[a-z0-9]+([_\\.-][a-z0-9]+)*"."@([a-z0-9]+([\.-][a-z0-9]+))*$",$mail, $regs) ) {    if( !eregi("^[a-z0-9]+([_\\.-][a-z0-9]+)*"."@([a-z0-9]+([\.-][a-z0-9]+))*$",$mail, $regs) ) {
78          return "format";          return "format";
# Line 152  function dprint($message) { Line 158  function dprint($message) {
158  }  }
159  */  */
160    
161    function number_format_storage($string) {
162        $locale_info = localeconv();
163        $string =  str_replace($locale_info["decimal_point"], ".",  $string);
164        return $string;
165    }
166    
167    function number_format_locale1($string) {
168        $locale_info = localeconv();
169        $string =  str_replace(".", $locale_info["decimal_point"],  $string);
170        return $string;
171    }
172    
173    
174    function number_format_locale ($num, $decimals = null) {
175       $locale = localeconv();
176       if(!isset($decimals)) $decimals = $locale['frac_digits'];
177       return number_format($num, $decimals, $locale['decimal_point'], $locale['thousands_sep']);
178    }
179    
180    
181    function is_amount($amount) {
182      //if( (number_format_locale((string)doubleval($amount)) === number_format_locale((string)$amount)) && number_format_locale((doubleval($amount)) >number_format_locale(0)) ) {
183      if( ((string)doubleval($amount) === (string)$amount) && (doubleval($amount) > 0) ) {
184        return 1;
185      }
186    }
187    
188  ?>  ?>

Legend:
Removed from v.1.3  
changed lines
  Added in v.1.4

MailToCvsAdmin">MailToCvsAdmin
ViewVC Help
Powered by ViewVC 1.1.26 RSS 2.0 feed