PHPExcel_Style
[ class tree: PHPExcel_Style ] [ index: PHPExcel_Style ] [ all elements ]

Source for file NumberFormat.php

Documentation is available at NumberFormat.php

  1. <?php
  2. /**
  3.  * PHPExcel
  4.  *
  5.  * Copyright (c) 2006 - 2009 PHPExcel
  6.  *
  7.  * This library is free software; you can redistribute it and/or
  8.  * modify it under the terms of the GNU Lesser General Public
  9.  * License as published by the Free Software Foundation; either
  10.  * version 2.1 of the License, or (at your option) any later version.
  11.  *
  12.  * This library is distributed in the hope that it will be useful,
  13.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  15.  * Lesser General Public License for more details.
  16.  *
  17.  * You should have received a copy of the GNU Lesser General Public
  18.  * License along with this library; if not, write to the Free Software
  19.  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
  20.  *
  21.  * @category   PHPExcel
  22.  * @package    PHPExcel_Style
  23.  * @copyright  Copyright (c) 2006 - 2009 PHPExcel (http://www.codeplex.com/PHPExcel)
  24.  * @license    http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt    LGPL
  25.  * @version    1.7.0, 2009-08-10
  26.  */
  27.  
  28.  
  29. /** PHPExcel root directory */
  30. if (!defined('PHPEXCEL_ROOT')) {
  31.     /**
  32.      * @ignore
  33.      */
  34.     define('PHPEXCEL_ROOT'dirname(__FILE__'/../../');
  35. }
  36.  
  37. /** PHPExcel_IComparable */
  38. require_once PHPEXCEL_ROOT 'PHPExcel/IComparable.php';
  39.  
  40. /** PHPExcel_Shared_Date */
  41. require_once PHPEXCEL_ROOT 'PHPExcel/Shared/Date.php';
  42.  
  43. /** PHPExcel_Calculation_Functions */
  44. require_once PHPEXCEL_ROOT 'PHPExcel/Calculation/Functions.php';
  45.  
  46.  
  47. /**
  48.  * PHPExcel_Style_NumberFormat
  49.  *
  50.  * @category   PHPExcel
  51.  * @package    PHPExcel_Style
  52.  * @copyright  Copyright (c) 2006 - 2009 PHPExcel (http://www.codeplex.com/PHPExcel)
  53.  */
  54. class PHPExcel_Style_NumberFormat implements PHPExcel_IComparable
  55. {
  56.     /* Pre-defined formats */
  57.     const FORMAT_GENERAL                    'General';
  58.  
  59.     const FORMAT_TEXT                        '@';
  60.  
  61.     const FORMAT_NUMBER                        '0';
  62.     const FORMAT_NUMBER_00                    '0.00';
  63.     const FORMAT_NUMBER_COMMA_SEPARATED1    '#,##0.00';
  64.     const FORMAT_NUMBER_COMMA_SEPARATED2    '#,##0.00_-';
  65.  
  66.     const FORMAT_PERCENTAGE                    '0%';
  67.     const FORMAT_PERCENTAGE_00                '0.00%';
  68.  
  69.     const FORMAT_DATE_YYYYMMDD2                'yyyy-mm-dd';
  70.     const FORMAT_DATE_YYYYMMDD                'yy-mm-dd';
  71.     const FORMAT_DATE_DDMMYYYY                'dd/mm/yy';
  72.     const FORMAT_DATE_DMYSLASH                'd/m/y';
  73.     const FORMAT_DATE_DMYMINUS                'd-m-y';
  74.     const FORMAT_DATE_DMMINUS                'd-m';
  75.     const FORMAT_DATE_MYMINUS                'm-y';
  76.     const FORMAT_DATE_XLSX14                'mm-dd-yy';
  77.     const FORMAT_DATE_XLSX15                'd-mmm-yy';
  78.     const FORMAT_DATE_XLSX16                'd-mmm';
  79.     const FORMAT_DATE_XLSX17                'mmm-yy';
  80.     const FORMAT_DATE_XLSX22                'm/d/yy h:mm';
  81.     const FORMAT_DATE_DATETIME                'd/m/y h:mm';
  82.     const FORMAT_DATE_TIME1                    'h:mm AM/PM';
  83.     const FORMAT_DATE_TIME2                    'h:mm:ss AM/PM';
  84.     const FORMAT_DATE_TIME3                    'h:mm';
  85.     const FORMAT_DATE_TIME4                    'h:mm:ss';
  86.     const FORMAT_DATE_TIME5                    'mm:ss';
  87.     const FORMAT_DATE_TIME6                    'h:mm:ss';
  88.     const FORMAT_DATE_TIME7                    'i:s.S';
  89.     const FORMAT_DATE_TIME8                    'h:mm:ss;@';
  90.     const FORMAT_DATE_YYYYMMDDSLASH            'yy/mm/dd;@';
  91.  
  92.     const FORMAT_CURRENCY_USD_SIMPLE        '"$"#,##0.00_-';
  93.     const FORMAT_CURRENCY_USD                '$#,##0_-';
  94.     const FORMAT_CURRENCY_EUR_SIMPLE        '[$EUR ]#,##0.00_-';
  95.  
  96.     /**
  97.      * Excel built-in number formats
  98.      *
  99.      * @var array 
  100.      */
  101.     private static $_builtInFormats;
  102.  
  103.     /**
  104.      * Excel built-in number formats (flipped, for faster lookups)
  105.      *
  106.      * @var array 
  107.      */
  108.     private static $_flippedBuiltInFormats;
  109.  
  110.     /**
  111.      * Format Code
  112.      *
  113.      * @var string 
  114.      */
  115.     private $_formatCode;
  116.  
  117.     /**
  118.      * Built-in format Code
  119.      *
  120.      * @var string 
  121.      */
  122.     private $_builtInFormatCode;
  123.  
  124.     /**
  125.      * Parent Borders
  126.      *
  127.      * @var _parentPropertyName string
  128.      */
  129.     private $_parentPropertyName;
  130.  
  131.     /**
  132.      * Supervisor?
  133.      *
  134.      * @var boolean 
  135.      */
  136.     private $_isSupervisor;
  137.  
  138.     /**
  139.      * Parent. Only used for supervisor
  140.      *
  141.      * @var PHPExcel_Style 
  142.      */
  143.     private $_parent;
  144.  
  145.     /**
  146.      * Create a new PHPExcel_Style_NumberFormat
  147.      */
  148.     public function __construct($isSupervisor false)
  149.     {
  150.         // Supervisor?
  151.         $this->_isSupervisor = $isSupervisor;
  152.  
  153.         // Initialise values
  154.         $this->_formatCode            = PHPExcel_Style_NumberFormat::FORMAT_GENERAL;
  155.         $this->_builtInFormatCode    = 0;
  156.     }
  157.  
  158.     /**
  159.      * Bind parent. Only used for supervisor
  160.      *
  161.      * @param PHPExcel_Style $parent 
  162.      * @return PHPExcel_Style_NumberFormat 
  163.      */
  164.     public function bindParent($parent)
  165.     {
  166.         $this->_parent = $parent;
  167.     }
  168.  
  169.     /**
  170.      * Is this a supervisor or a real style component?
  171.      *
  172.      * @return boolean 
  173.      */
  174.     public function getIsSupervisor()
  175.     {
  176.         return $this->_isSupervisor;
  177.     }
  178.  
  179.     /**
  180.      * Get the shared style component for the currently active cell in currently active sheet.
  181.      * Only used for style supervisor
  182.      *
  183.      * @return PHPExcel_Style_NumberFormat 
  184.      */
  185.     public function getSharedComponent()
  186.     {
  187.         return $this->_parent->getSharedComponent()->getNumberFormat();
  188.     }
  189.  
  190.     /**
  191.      * Get the currently active sheet. Only used for supervisor
  192.      *
  193.      * @return PHPExcel_Worksheet 
  194.      */
  195.     public function getActiveSheet()
  196.     {
  197.         return $this->_parent->getActiveSheet();
  198.     }
  199.  
  200.     /**
  201.      * Get the currently active cell coordinate in currently active sheet.
  202.      * Only used for supervisor
  203.      *
  204.      * @return string E.g. 'A1'
  205.      */
  206.     public function getXSelectedCells()
  207.     {
  208.         return $this->getActiveSheet()->getXSelectedCells();
  209.     }
  210.  
  211.     /**
  212.      * Get the currently active cell coordinate in currently active sheet.
  213.      * Only used for supervisor
  214.      *
  215.      * @return string E.g. 'A1'
  216.      */
  217.     public function getXActiveCell()
  218.     {
  219.         return $this->getActiveSheet()->getXActiveCell();
  220.     }
  221.  
  222.     /**
  223.      * Build style array from subcomponents
  224.      *
  225.      * @param array $array 
  226.      * @return array 
  227.      */
  228.     public function getStyleArray($array)
  229.     {
  230.         return array('numberformat' => $array);
  231.     }
  232.  
  233.     /**
  234.      * Apply styles from array
  235.      *
  236.      * <code>
  237.      * $objPHPExcel->getActiveSheet()->getStyle('B2')->getNumberFormat()->applyFromArray(
  238.      *         array(
  239.      *             'code' => PHPExcel_Style_NumberFormat::FORMAT_CURRENCY_EUR_SIMPLE
  240.      *         )
  241.      * );
  242.      * </code>
  243.      *
  244.      * @param    array    $pStyles    Array containing style information
  245.      * @throws    Exception
  246.      * @return PHPExcel_Style_NumberFormat 
  247.      */
  248.     public function applyFromArray($pStyles null{
  249.         if (is_array($pStyles)) {
  250.             if ($this->_isSupervisor{
  251.                 $this->getActiveSheet()->getStyle($this->getXSelectedCells())->applyFromArray($this->getStyleArray($pStyles));
  252.             else {
  253.                 if (array_key_exists('code'$pStyles)) {
  254.                     $this->setFormatCode($pStyles['code']);
  255.                 }
  256.             }
  257.         else {
  258.             throw new Exception("Invalid style array passed.");
  259.         }
  260.         return $this;
  261.     }
  262.  
  263.     /**
  264.      * Get Format Code
  265.      *
  266.      * @return string 
  267.      */
  268.     public function getFormatCode({
  269.         if ($this->_isSupervisor{
  270.             return $this->getSharedComponent()->getFormatCode();
  271.         }
  272.         if ($this->_builtInFormatCode !== false)
  273.         {
  274.             return self::builtInFormatCode($this->_builtInFormatCode);
  275.         }
  276.         return $this->_formatCode;
  277.     }
  278.  
  279.     /**
  280.      * Set Format Code
  281.      *
  282.      * @param string $pValue 
  283.      * @return PHPExcel_Style_NumberFormat 
  284.      */
  285.     public function setFormatCode($pValue PHPExcel_Style_NumberFormat::FORMAT_GENERAL{
  286.         if ($pValue == ''{
  287.             $pValue PHPExcel_Style_NumberFormat::FORMAT_GENERAL;
  288.         }
  289.         if ($this->_isSupervisor{
  290.             $styleArray $this->getStyleArray(array('code' => $pValue));
  291.             $this->getActiveSheet()->getStyle($this->getXSelectedCells())->applyFromArray($styleArray);
  292.         else {
  293.             $this->_formatCode = $pValue;
  294.             $this->_builtInFormatCode = self::builtInFormatCodeIndex($pValue);
  295.         }
  296.         return $this;
  297.     }
  298.  
  299.     /**
  300.      * Get Built-In Format Code
  301.      *
  302.      * @return int 
  303.      */
  304.     public function getBuiltInFormatCode({
  305.         if ($this->_isSupervisor{
  306.             return $this->getSharedComponent()->getBuiltInFormatCode();
  307.         }
  308.         return $this->_builtInFormatCode;
  309.     }
  310.  
  311.     /**
  312.      * Set Built-In Format Code
  313.      *
  314.      * @param int $pValue 
  315.      * @return PHPExcel_Style_NumberFormat 
  316.      */
  317.     public function setBuiltInFormatCode($pValue 0{
  318.  
  319.         if ($this->_isSupervisor{
  320.             $styleArray $this->getStyleArray(array('code' => self::builtInFormatCode($pValue)));
  321.             $this->getActiveSheet()->getStyle($this->getXSelectedCells())->applyFromArray($styleArray);
  322.         else {
  323.             $this->_builtInFormatCode = $pValue;
  324.             $this->_formatCode = self::builtInFormatCode($pValue);
  325.         }
  326.         return $this;
  327.     }
  328.  
  329.     /**
  330.      * Fill built-in format codes
  331.      */
  332.     private static function fillBuiltInFormatCodes()
  333.     {
  334.         // Built-in format codes
  335.         if (is_null(self::$_builtInFormats)) {
  336.             self::$_builtInFormats array();
  337.  
  338.             // General
  339.             self::$_builtInFormats[0'General';
  340.             self::$_builtInFormats[1'0';
  341.             self::$_builtInFormats[2'0.00';
  342.             self::$_builtInFormats[3'#,##0';
  343.             self::$_builtInFormats[4'#,##0.00';
  344.  
  345.             self::$_builtInFormats[9'0%';
  346.             self::$_builtInFormats[10'0.00%';
  347.             self::$_builtInFormats[11'0.00E+00';
  348.             self::$_builtInFormats[12'# ?/?';
  349.             self::$_builtInFormats[13'# ??/??';
  350.             self::$_builtInFormats[14'mm-dd-yy';
  351.             self::$_builtInFormats[15'd-mmm-yy';
  352.             self::$_builtInFormats[16'd-mmm';
  353.             self::$_builtInFormats[17'mmm-yy';
  354.             self::$_builtInFormats[18'h:mm AM/PM';
  355.             self::$_builtInFormats[19'h:mm:ss AM/PM';
  356.             self::$_builtInFormats[20'h:mm';
  357.             self::$_builtInFormats[21'h:mm:ss';
  358.             self::$_builtInFormats[22'm/d/yy h:mm';
  359.  
  360.             self::$_builtInFormats[37'#,##0 ;(#,##0)';
  361.             self::$_builtInFormats[38'#,##0 ;[Red](#,##0)';
  362.             self::$_builtInFormats[39'#,##0.00;(#,##0.00)';
  363.             self::$_builtInFormats[40'#,##0.00;[Red](#,##0.00)';
  364.  
  365.             self::$_builtInFormats[44'_("$"* #,##0.00_);_("$"* \(#,##0.00\);_("$"* "-"??_);_(@_)';
  366.             self::$_builtInFormats[45'mm:ss';
  367.             self::$_builtInFormats[46'[h]:mm:ss';
  368.             self::$_builtInFormats[47'mmss.0';
  369.             self::$_builtInFormats[48'##0.0E+0';
  370.             self::$_builtInFormats[49'@';
  371.  
  372.             // CHT
  373.             self::$_builtInFormats[27'[$-404]e/m/d';
  374.             self::$_builtInFormats[30'm/d/yy';
  375.             self::$_builtInFormats[36'[$-404]e/m/d';
  376.             self::$_builtInFormats[50'[$-404]e/m/d';
  377.             self::$_builtInFormats[57'[$-404]e/m/d';
  378.  
  379.             // THA
  380.             self::$_builtInFormats[59't0';
  381.             self::$_builtInFormats[60't0.00';
  382.             self::$_builtInFormats[61't#,##0';
  383.             self::$_builtInFormats[62't#,##0.00';
  384.             self::$_builtInFormats[67't0%';
  385.             self::$_builtInFormats[68't0.00%';
  386.             self::$_builtInFormats[69't# ?/?';
  387.             self::$_builtInFormats[70't# ??/??';
  388.  
  389.             // Flip array (for faster lookups)
  390.             self::$_flippedBuiltInFormats array_flip(self::$_builtInFormats);
  391.         }
  392.     }
  393.  
  394.     /**
  395.      * Get built-in format code
  396.      *
  397.      * @param    int        $pIndex 
  398.      * @return    string 
  399.      */
  400.     public static function builtInFormatCode($pIndex{
  401.         // Clean parameter
  402.         $pIndex intval($pIndex);
  403.  
  404.         // Ensure built-in format codes are available
  405.         self::fillBuiltInFormatCodes();
  406.  
  407.         // Lookup format code
  408.         if (array_key_exists($pIndexself::$_builtInFormats)) {
  409.             return self::$_builtInFormats[$pIndex];
  410.         }
  411.  
  412.         return '';
  413.     }
  414.  
  415.     /**
  416.      * Get built-in format code index
  417.      *
  418.      * @param    string        $formatCode 
  419.      * @return    int|boolean
  420.      */
  421.     public static function builtInFormatCodeIndex($formatCode{
  422.         // Ensure built-in format codes are available
  423.         self::fillBuiltInFormatCodes();
  424.  
  425.         // Lookup format code
  426.         if (array_key_exists($formatCodeself::$_flippedBuiltInFormats)) {
  427.             return self::$_flippedBuiltInFormats[$formatCode];
  428.         }
  429.  
  430.         return false;
  431.     }
  432.  
  433.     /**
  434.      * Get hash code
  435.      *
  436.      * @return string    Hash code
  437.      */
  438.     public function getHashCode({
  439.         if ($this->_isSupervisor{
  440.             return $this->getSharedComponent()->getHashCode();
  441.         }
  442.         return md5(
  443.               $this->_formatCode
  444.             . $this->_builtInFormatCode
  445.             . __CLASS__
  446.         );
  447.     }
  448.  
  449.     /**
  450.      * Hash index
  451.      *
  452.      * @var string 
  453.      */
  454.     private $_hashIndex;
  455.  
  456.     /**
  457.      * Get hash index
  458.      *
  459.      * Note that this index may vary during script execution! Only reliable moment is
  460.      * while doing a write of a workbook and when changes are not allowed.
  461.      *
  462.      * @return string    Hash index
  463.      */
  464.     public function getHashIndex({
  465.         return $this->_hashIndex;
  466.     }
  467.  
  468.     /**
  469.      * Set hash index
  470.      *
  471.      * Note that this index may vary during script execution! Only reliable moment is
  472.      * while doing a write of a workbook and when changes are not allowed.
  473.      *
  474.      * @param string    $value    Hash index
  475.      */
  476.     public function setHashIndex($value{
  477.         $this->_hashIndex = $value;
  478.     }
  479.  
  480.     /**
  481.      * Implement PHP __clone to create a deep clone, not just a shallow copy.
  482.      */
  483.     public function __clone({
  484.         $vars get_object_vars($this);
  485.         foreach ($vars as $key => $value{
  486.             if (is_object($value)) {
  487.                 $this->$key clone $value;
  488.             else {
  489.                 $this->$key $value;
  490.             }
  491.         }
  492.     }
  493.  
  494.     /**
  495.      * Convert a value in a pre-defined format to a PHP string
  496.      *
  497.      * @param mixed     $value        Value to format
  498.      * @param string     $format        Format code
  499.      * @return string    Formatted string
  500.      */
  501.     public static function toFormattedString($value ''$format ''{
  502.         // For now we do not treat strings although part 4 of a format code affects strings
  503.         if (!is_numeric($value)) return $value;
  504.  
  505.         // For 'General' format code, we just pass the value although this is not entirely the way Excel does it,
  506.         // it seems to round numbers to a total of 10 digits.
  507.         if ($format === 'General'{
  508.             return $value;
  509.         }
  510.  
  511.         // Get the parts, there can be up to four parts
  512.         $parts explode(';'$format);
  513.  
  514.         // We should really fetch the relevant part depending on whether we have a positive number,
  515.         // negative number, zero, or text. But for now we just use first part
  516.         $format $parts[0];
  517.  
  518.         if (preg_match("/^[hmsdy]/i"$format)) // custom datetime format
  519.             // dvc: convert Excel formats to PHP date formats
  520.             // first remove escapes related to non-format characters
  521.  
  522.             // OpenOffice.org uses upper-case number formats, e.g. 'YYYY', convert to lower-case
  523.             $format strtolower($format);
  524.  
  525.             $format str_replace('\\'''$format);
  526.  
  527.             //    4-digit year
  528.             $format str_replace('yyyy''Y'$format);
  529.             //    2-digit year
  530.             $format str_replace('yy''y'$format);
  531.             //    first letter of month - no php equivalent
  532.             $format str_replace('mmmmm''M'$format);
  533.             //    full month name
  534.             $format str_replace('mmmm''F'$format);
  535.             //    short month name
  536.             $format str_replace('mmm''M'$format);
  537.             //    mm is minutes if time or month w/leading zero
  538.             $format str_replace(':mm'':i'$format);
  539.             //    tmp place holder
  540.             $format str_replace('mm''x'$format);
  541.             //    month no leading zero
  542.             $format str_replace('m''n'$format);
  543.             //    month leading zero
  544.             $format str_replace('x''m'$format);
  545.             //    12-hour suffix
  546.             $format str_replace('am/pm''A'$format);
  547.             //    full day of week name
  548.             $format str_replace('dddd''l'$format);
  549.             //    short day of week name
  550.             $format str_replace('ddd''D'$format);
  551.             //    tmp place holder
  552.             $format str_replace('dd''x'$format);
  553.             //    days no leading zero
  554.             $format str_replace('d''j'$format);
  555.             //    days leading zero
  556.             $format str_replace('x''d'$format);
  557.             //    seconds
  558.             $format str_replace('ss''s'$format);
  559.             //    fractional seconds - no php equivalent
  560.             $format str_replace('.s'''$format);
  561.  
  562.             if (!strpos($format,'A')) // 24-hour format
  563.                 $format str_replace('h''H'$format);
  564.             }
  565.  
  566.             return gmdate($formatPHPExcel_Shared_Date::ExcelToPHP($value));
  567.  
  568.         else if (preg_match('/%$/'$format)) // % number format
  569.             if ($format === self::FORMAT_PERCENTAGE{
  570.                 return round( (100 $value)0'%';
  571.             }
  572.             if (preg_match('/\.[#0]+/i'$format$m)) {
  573.                 $s substr($m[0]01(strlen($m[0]1);
  574.                 $format str_replace($m[0]$s$format);
  575.             }
  576.             if (preg_match('/^[#0]+/'$format$m)) {
  577.                 $format str_replace($m[0]strlen($m[0])$format);
  578.             }
  579.             $format '%' str_replace('%''f%%'$format);
  580.  
  581.             return sprintf($format100 $value);
  582.  
  583.         else {
  584.             if (preg_match ("/^([0-9.,-]+)$/"$value)) {
  585.                  if ($format === self::FORMAT_CURRENCY_EUR_SIMPLE{
  586.                      return 'EUR ' sprintf('%1.2f'$value);
  587.  
  588.                 else {
  589.                     // In Excel formats, "_" is used to add spacing, which we can't do in HTML
  590.                     $format preg_replace('/_./'''$format);
  591.  
  592.                     // Some non-number characters are escaped with \, which we don't need
  593.                     $format preg_replace("/\\\\/"''$format);
  594.  
  595.                     // Some non-number strings are quoted, so we'll get rid of the quotes
  596.                     $format preg_replace('/"/'''$format);
  597.  
  598.                     // TEMPORARY - Convert # to 0
  599.                     $format preg_replace('/\\#/''0'$format);
  600.  
  601.                     // Find out if we need thousands separator
  602.                     $useThousands preg_match('/,/'$format);
  603.                     if ($useThousands{
  604.                         $format preg_replace('/,/'''$format);
  605.                     }
  606.  
  607.                     if (preg_match('/0?.*\?\/\?/'$format$m)) {
  608.                         //echo 'Format mask is fractional '.$format.' <br />';
  609.                         $sign ($value 0'-' '';
  610.  
  611.                         $integerPart floor(abs($value));
  612.                         $decimalPart trim(fmod(abs($value),1),'0.');
  613.                         $decimalLength strlen($decimalPart);
  614.                         $decimalDivisor pow(10,$decimalLength);
  615.  
  616.                         $GCD PHPExcel_Calculation_Functions::GCD($decimalPart,$decimalDivisor);
  617.  
  618.                         $adjustedDecimalPart $decimalPart/$GCD;
  619.                         $adjustedDecimalDivisor $decimalDivisor/$GCD;
  620.  
  621.                         if (strpos($format,'0'!== false{
  622.                             $value "$sign$integerPart $adjustedDecimalPart/$adjustedDecimalDivisor";
  623.                         else {
  624.                             $adjustedDecimalPart += $integerPart $adjustedDecimalDivisor;
  625.                             $value "$sign$adjustedDecimalPart/$adjustedDecimalDivisor";
  626.                         }
  627.  
  628.                     else {
  629.                         // Handle the number itself
  630.                         $number_regex "/(\d+)(\.?)(\d*)/";
  631.                         if (preg_match($number_regex$format$matches)) {
  632.                             $left $matches[1];
  633.                             $dec $matches[2];
  634.                             $right $matches[3];
  635.                             if ($useThousands{
  636.                                 $localeconv localeconv();
  637.                                 if (($localeconv['thousands_sep'== ''|| ($localeconv['decimal_point'== '')) {
  638.                                     $value number_format($valuestrlen($right)$localeconv['mon_decimal_point']$localeconv['mon_thousands_sep']);
  639.                                 else {
  640.                                     $value number_format($valuestrlen($right)$localeconv['decimal_point']$localeconv['thousands_sep']);
  641.                                 }
  642.                             else {
  643.                                 $sprintf_pattern "%1." strlen($right"f";
  644.                                 $value sprintf($sprintf_pattern$value);
  645.                             }
  646.                             $value preg_replace($number_regex$value$format);
  647.                         }
  648.                     }
  649.  
  650.                     return $value;
  651.  
  652.                 }
  653.             }
  654.  
  655.             return $value;
  656.         }
  657.     }
  658. }

Documentation generated on Mon, 10 Aug 2009 08:06:43 +0200 by phpDocumentor 1.4.1