@@ -689,100 +689,6 @@ function atanh($x) {
689
689
} // function atanh()
690
690
}
691
691
692
- if (!function_exists ('money_format ' )) {
693
- function money_format ($ format , $ number ) {
694
- $ regex = array ( '/%((?:[\^!\-]|\+|\(|\=.)*)([0-9]+)?(?:#([0-9]+))? ' ,
695
- '(?:\.([0-9]+))?([in%])/ '
696
- );
697
- $ regex = implode ('' , $ regex );
698
- if (setlocale (LC_MONETARY , null ) == '' ) {
699
- setlocale (LC_MONETARY , '' );
700
- }
701
- $ locale = localeconv ();
702
- $ number = floatval ($ number );
703
- if (!preg_match ($ regex , $ format , $ fmatch )) {
704
- trigger_error ("No format specified or invalid format " , E_USER_WARNING );
705
- return $ number ;
706
- }
707
- $ flags = array ( 'fillchar ' => preg_match ('/\=(.)/ ' , $ fmatch [1 ], $ match ) ? $ match [1 ] : ' ' ,
708
- 'nogroup ' => preg_match ('/\^/ ' , $ fmatch [1 ]) > 0 ,
709
- 'usesignal ' => preg_match ('/\+|\(/ ' , $ fmatch [1 ], $ match ) ? $ match [0 ] : '+ ' ,
710
- 'nosimbol ' => preg_match ('/\!/ ' , $ fmatch [1 ]) > 0 ,
711
- 'isleft ' => preg_match ('/\-/ ' , $ fmatch [1 ]) > 0
712
- );
713
- $ width = trim ($ fmatch [2 ]) ? (int )$ fmatch [2 ] : 0 ;
714
- $ left = trim ($ fmatch [3 ]) ? (int )$ fmatch [3 ] : 0 ;
715
- $ right = trim ($ fmatch [4 ]) ? (int )$ fmatch [4 ] : $ locale ['int_frac_digits ' ];
716
- $ conversion = $ fmatch [5 ];
717
- $ positive = true ;
718
- if ($ number < 0 ) {
719
- $ positive = false ;
720
- $ number *= -1 ;
721
- }
722
- $ letter = $ positive ? 'p ' : 'n ' ;
723
- $ prefix = $ suffix = $ cprefix = $ csuffix = $ signal = '' ;
724
- if (!$ positive ) {
725
- $ signal = $ locale ['negative_sign ' ];
726
- switch (true ) {
727
- case $ locale ['n_sign_posn ' ] == 0 || $ flags ['usesignal ' ] == '( ' :
728
- $ prefix = '( ' ;
729
- $ suffix = ') ' ;
730
- break ;
731
- case $ locale ['n_sign_posn ' ] == 1 :
732
- $ prefix = $ signal ;
733
- break ;
734
- case $ locale ['n_sign_posn ' ] == 2 :
735
- $ suffix = $ signal ;
736
- break ;
737
- case $ locale ['n_sign_posn ' ] == 3 :
738
- $ cprefix = $ signal ;
739
- break ;
740
- case $ locale ['n_sign_posn ' ] == 4 :
741
- $ csuffix = $ signal ;
742
- break ;
743
- }
744
- }
745
- if (!$ flags ['nosimbol ' ]) {
746
- $ currency = $ cprefix ;
747
- $ currency .= ($ conversion == 'i ' ? $ locale ['int_curr_symbol ' ] : $ locale ['currency_symbol ' ]);
748
- $ currency .= $ csuffix ;
749
- $ currency = iconv ('ISO-8859-1 ' ,'UTF-8 ' ,$ currency );
750
- } else {
751
- $ currency = '' ;
752
- }
753
- $ space = $ locale ["{$ letter }_sep_by_space " ] ? ' ' : '' ;
754
-
755
- if (!isset ($ locale ['mon_decimal_point ' ]) || empty ($ locale ['mon_decimal_point ' ])) {
756
- $ locale ['mon_decimal_point ' ] = (!isset ($ locale ['decimal_point ' ]) || empty ($ locale ['decimal_point ' ])) ?
757
- $ locale ['decimal_point ' ] :
758
- '. ' ;
759
- }
760
-
761
- $ number = number_format ($ number , $ right , $ locale ['mon_decimal_point ' ], $ flags ['nogroup ' ] ? '' : $ locale ['mon_thousands_sep ' ] );
762
- $ number = explode ($ locale ['mon_decimal_point ' ], $ number );
763
-
764
- $ n = strlen ($ prefix ) + strlen ($ currency );
765
- if ($ left > 0 && $ left > $ n ) {
766
- if ($ flags ['isleft ' ]) {
767
- $ number [0 ] .= str_repeat ($ flags ['fillchar ' ], $ left - $ n );
768
- } else {
769
- $ number [0 ] = str_repeat ($ flags ['fillchar ' ], $ left - $ n ) . $ number [0 ];
770
- }
771
- }
772
- $ number = implode ($ locale ['mon_decimal_point ' ], $ number );
773
- if ($ locale ["{$ letter }_cs_precedes " ]) {
774
- $ number = $ prefix . $ currency . $ space . $ number . $ suffix ;
775
- } else {
776
- $ number = $ prefix . $ number . $ space . $ currency . $ suffix ;
777
- }
778
- if ($ width > 0 ) {
779
- $ number = str_pad ($ number , $ width , $ flags ['fillchar ' ], $ flags ['isleft ' ] ? STR_PAD_RIGHT : STR_PAD_LEFT );
780
- }
781
- $ format = str_replace ($ fmatch [0 ], $ number , $ format );
782
- return $ format ;
783
- } // function money_format()
784
- }
785
-
786
692
787
693
//
788
694
// Strangely, PHP doesn't have a mb_str_replace multibyte function
0 commit comments