/** * Returns a locale formatted number depending on the given options. * The seperation and fraction sign is used from the set locale. * ##0.# -> 12345.12345 -> 12345.12345 * ##0.00 -> 12345.12345 -> 12345.12 * ##,##0.00 -> 12345.12345 -> 12,345.12 * * @param string $input Localized number string * @param array $options Options: number_format, locale, precision. See {@link setOptions()} for details. * @return string locale formatted number * @throws Zend_Locale_Exception */ public static function toNumber($value, array $options = array()) { // load class within method for speed // require_once 'Zend/Locale/Math.php'; $value = Zend_Locale_Math::normalize($value); $value = Zend_Locale_Math::floatalize($value); $options = self::_checkOptions($options) + self::$_options; $options['locale'] = (string) $options['locale']; // Get correct signs for this locale $symbols = Zend_Locale_Data::getList($options['locale'], 'symbols'); $oenc = iconv_get_encoding('internal_encoding'); iconv_set_encoding('internal_encoding', 'UTF-8'); // Get format $format = $options['number_format']; if ($format === null) { $format = Zend_Locale_Data::getContent($options['locale'], 'decimalnumber'); $format = self::_seperateFormat($format, $value, $options['precision']); if ($options['precision'] !== null) { $value = Zend_Locale_Math::normalize(Zend_Locale_Math::round($value, $options['precision'])); } } else { // seperate negative format pattern when available $format = self::_seperateFormat($format, $value, $options['precision']); if (strpos($format, '.')) { if (is_numeric($options['precision'])) { $value = Zend_Locale_Math::round($value, $options['precision']); } else { if (substr($format, iconv_strpos($format, '.') + 1, 3) == '###') { $options['precision'] = null; } else { $options['precision'] = iconv_strlen(iconv_substr($format, iconv_strpos($format, '.') + 1, iconv_strrpos($format, '0') - iconv_strpos($format, '.'))); $format = iconv_substr($format, 0, iconv_strpos($format, '.') + 1) . '###' . iconv_substr($format, iconv_strrpos($format, '0') + 1); } } } else { $value = Zend_Locale_Math::round($value, 0); $options['precision'] = 0; } $value = Zend_Locale_Math::normalize($value); } if (iconv_strpos($format, '0') === false) { iconv_set_encoding('internal_encoding', $oenc); // require_once 'Zend/Locale/Exception.php'; throw new Zend_Locale_Exception('Wrong format... missing 0'); } // get number parts $pos = iconv_strpos($value, '.'); if ($pos !== false) { if ($options['precision'] === null) { $precstr = iconv_substr($value, $pos + 1); } else { $precstr = iconv_substr($value, $pos + 1, $options['precision']); if (iconv_strlen($precstr) < $options['precision']) { $precstr = $precstr . str_pad("0", $options['precision'] - iconv_strlen($precstr), "0"); } } } else { if ($options['precision'] > 0) { $precstr = str_pad("0", $options['precision'], "0"); } } if ($options['precision'] === null) { if (isset($precstr)) { $options['precision'] = iconv_strlen($precstr); } else { $options['precision'] = 0; } } // get fraction and format lengths if (strpos($value, '.') !== false) { $number = substr((string) $value, 0, strpos($value, '.')); } else { $number = $value; } $prec = call_user_func(Zend_Locale_Math::$sub, $value, $number, $options['precision']); $prec = Zend_Locale_Math::floatalize($prec); $prec = Zend_Locale_Math::normalize($prec); if (iconv_strpos($prec, '-') !== false) { $prec = iconv_substr($prec, 1); } if ($prec == 0 and $options['precision'] > 0) { $prec = "0.0"; } if ($options['precision'] + 2 > iconv_strlen($prec)) { $prec = str_pad((string) $prec, $options['precision'] + 2, "0", STR_PAD_RIGHT); } if (iconv_strpos($number, '-') !== false) { $number = iconv_substr($number, 1); } $group = iconv_strrpos($format, ','); $group2 = iconv_strpos($format, ','); $point = iconv_strpos($format, '0'); // Add fraction $rest = ""; if (iconv_strpos($format, '.')) { $rest = iconv_substr($format, iconv_strpos($format, '.') + 1); $length = iconv_strlen($rest); for ($x = 0; $x < $length; ++$x) { if ($rest[0] == '0' || $rest[0] == '#') { $rest = iconv_substr($rest, 1); } } $format = iconv_substr($format, 0, iconv_strlen($format) - iconv_strlen($rest)); } if ($options['precision'] == '0') { if (iconv_strrpos($format, '-') != 0) { $format = iconv_substr($format, 0, $point) . iconv_substr($format, iconv_strrpos($format, '#') + 2); } else { $format = iconv_substr($format, 0, $point); } } else { $format = iconv_substr($format, 0, $point) . $symbols['decimal'] . iconv_substr($prec, 2); } $format .= $rest; // Add seperation if ($group == 0) { // no seperation $format = $number . iconv_substr($format, $point); } else { if ($group == $group2) { // only 1 seperation $seperation = $point - $group; for ($x = iconv_strlen($number); $x > $seperation; $x -= $seperation) { if (iconv_substr($number, 0, $x - $seperation) !== "") { $number = iconv_substr($number, 0, $x - $seperation) . $symbols['group'] . iconv_substr($number, $x - $seperation); } } $format = iconv_substr($format, 0, iconv_strpos($format, '#')) . $number . iconv_substr($format, $point); } else { // 2 seperations if (iconv_strlen($number) > $point - $group) { $seperation = $point - $group; $number = iconv_substr($number, 0, iconv_strlen($number) - $seperation) . $symbols['group'] . iconv_substr($number, iconv_strlen($number) - $seperation); if (iconv_strlen($number) - 1 > $point - $group + 1) { $seperation2 = $group - $group2 - 1; for ($x = iconv_strlen($number) - $seperation2 - 2; $x > $seperation2; $x -= $seperation2) { $number = iconv_substr($number, 0, $x - $seperation2) . $symbols['group'] . iconv_substr($number, $x - $seperation2); } } } $format = iconv_substr($format, 0, iconv_strpos($format, '#')) . $number . iconv_substr($format, $point); } } // set negative sign if (call_user_func(Zend_Locale_Math::$comp, $value, 0, $options['precision']) < 0) { if (iconv_strpos($format, '-') === false) { $format = $symbols['minus'] . $format; } else { $format = str_replace('-', $symbols['minus'], $format); } } iconv_set_encoding('internal_encoding', $oenc); return (string) $format; }
/** * Returns a locale formatted number depending on the given options. * The seperation and fraction sign is used from the set locale. * ##0.# -> 12345.12345 -> 12345.12345 * ##0.00 -> 12345.12345 -> 12345.12 * ##,##0.00 -> 12345.12345 -> 12,345.12 * * @param string $input Localized number string * @param array $options Options: number_format, locale, precision. See {@link setOptions()} for details. * @return string locale formatted number */ public static function toNumber($value, array $options = array()) { $value = Zend_Locale_Math::normalize($value); $options = array_merge(self::$_Options, self::checkOptions($options)); if ($options['locale'] instanceof Zend_Locale) { $options['locale'] = $options['locale']->toString(); } // Get correct signs for this locale $symbols = Zend_Locale_Data::getContent($options['locale'], 'numbersymbols'); iconv_set_encoding('internal_encoding', 'UTF-8'); // Get format $format = $options['number_format']; if ($format === null) { $format = Zend_Locale_Data::getContent($options['locale'], 'decimalnumberformat'); $format = $format['default']; if (iconv_strpos($format, ';') !== false) { if (call_user_func(Zend_Locale_Math::$comp, $value, 0) < 0) { $format = iconv_substr($format, iconv_strpos($format, ';') + 1); } else { $format = iconv_substr($format, 0, iconv_strpos($format, ';')); } } } else { // seperate negative format pattern when avaiable if (iconv_strpos($format, ';') !== false) { if (call_user_func(Zend_Locale_Math::$comp, $value, 0) < 0) { $format = iconv_substr($format, iconv_strpos($format, ';') + 1); } else { $format = iconv_substr($format, 0, iconv_strpos($format, ';')); } } if (strpos($format, '.')) { if (is_numeric($options['precision'])) { $value = round($value, $options['precision']); } else { if (substr($format, strpos($format, '.') + 1, 3) == '###') { $options['precision'] = null; } else { $options['precision'] = strlen(substr($format, strpos($format, '.') + 1, strrpos($format, '0') - strpos($format, '.'))); $format = substr($format, 0, strpos($format, '.') + 1) . '###' . substr($format, strrpos($format, '0') + 1); } } } else { $value = round($value, 0); $options['precision'] = 0; } } // set negative sign if (call_user_func(Zend_Locale_Math::$comp, $value, 0) < 0) { if (iconv_strpos($format, '-') === false) { $format = $symbols['minus'] . $format; } else { $format = str_replace('-', $symbols['minus'], $format); } } // get number parts if (strlen($value) != strlen(round($value, 0))) { if ($options['precision'] === null) { $precstr = iconv_substr($value, strlen(round($value, 0)) + 1); } else { $precstr = iconv_substr($value, strlen(round($value, 0)) + 1, $options['precision']); if (iconv_strlen($precstr) < $options['precision']) { $precstr = $precstr . str_pad("0", $options['precision'] - iconv_strlen($precstr), "0"); } } } else { if ($options['precision'] > 0) { $precstr = str_pad("0", $options['precision'], "0"); } } if ($options['precision'] === null) { if (isset($precstr)) { $options['precision'] = iconv_strlen($precstr); } else { $options['precision'] = 0; } } // get fraction and format lengths $preg = call_user_func(Zend_Locale_Math::$sub, $value, '0', 0); $prec = call_user_func(Zend_Locale_Math::$sub, $value, $preg, $options['precision']); if (iconv_strpos($prec, '-') !== false) { $prec = iconv_substr($prec, 1); } if ($options['precision'] + 2 > strlen($prec)) { $prec = $prec . str_pad("0", $options['precision'] - iconv_strlen($prec), "0"); } $number = call_user_func(Zend_Locale_Math::$sub, $value, $prec, 0); if (iconv_strpos($number, '-') !== false) { $number = iconv_substr($number, 1); } $group = iconv_strrpos($format, ','); $group2 = iconv_strpos($format, ','); $point = iconv_strpos($format, '0'); // Add fraction $rest = ""; if ($value < 0 && strpos($format, '.')) { $rest = substr(substr($format, strpos($format, '.') + 1), -1, 1); } if ($options['precision'] == '0') { $format = iconv_substr($format, 0, $point) . iconv_substr($format, iconv_strrpos($format, '#') + 2); } else { $format = iconv_substr($format, 0, $point) . $symbols['decimal'] . iconv_substr($prec, 2) . iconv_substr($format, iconv_strrpos($format, '#') + 2); } if ($value < 0 and $rest != '0' and $rest != '#') { $format .= $rest; } // Add seperation if ($group == 0) { // no seperation $format = $number . iconv_substr($format, $point); } else { if ($group == $group2) { // only 1 seperation $seperation = $point - $group; for ($x = iconv_strlen($number); $x > $seperation; $x -= $seperation) { if (iconv_substr($number, 0, $x - $seperation) !== "") { $number = iconv_substr($number, 0, $x - $seperation) . $symbols['group'] . iconv_substr($number, $x - $seperation); } } $format = iconv_substr($format, 0, iconv_strpos($format, '#')) . $number . iconv_substr($format, $point); } else { // 2 seperations if (iconv_strlen($number) > $point - $group) { $seperation = $point - $group; $number = iconv_substr($number, 0, iconv_strlen($number) - $seperation) . $symbols['group'] . iconv_substr($number, iconv_strlen($number) - $seperation); if (iconv_strlen($number) - 1 > $point - $group + 1) { $seperation2 = $group - $group2 - 1; for ($x = iconv_strlen($number) - $seperation2 - 2; $x > $seperation2; $x -= $seperation2) { $number = iconv_substr($number, 0, $x - $seperation2) . $symbols['group'] . iconv_substr($number, $x - $seperation2); } } } $format = iconv_substr($format, 0, iconv_strpos($format, '#')) . $number . iconv_substr($format, $point); } } return (string) $format; }
/** * Returns a locale formatted number depending on the given options. * The seperation and fraction sign is used from the set locale. * ##0.# -> 12345.12345 -> 12345.12345 * ##0.00 -> 12345.12345 -> 12345.12 * ##,##0.00 -> 12345.12345 -> 12,345.12 * * @param string $input Localized number string * @param array $options Options: number_format, locale, precision. See {@link setOptions()} for details. * @return string locale formatted number */ public static function toNumber($value, array $options = array()) { // load class within method for speed require_once 'Zend/Locale/Math.php'; $value = Zend_Locale_Math::normalize($value); $options = array_merge(self::$_Options, self::checkOptions($options)); if ($options['locale'] instanceof Zend_Locale) { $options['locale'] = $options['locale']->toString(); } // Get correct signs for this locale $symbols = Zend_Locale_Data::getList($options['locale'], 'symbols'); iconv_set_encoding('internal_encoding', 'UTF-8'); // Get format $format = $options['number_format']; if ($format === null) { $format = Zend_Locale_Data::getContent($options['locale'], 'decimalnumber'); if (iconv_strpos($format, ';') !== false) { if (call_user_func(Zend_Locale_Math::$comp, $value, 0) < 0) { $format = iconv_substr($format, iconv_strpos($format, ';') + 1); } else { $format = iconv_substr($format, 0, iconv_strpos($format, ';')); } } } else { // seperate negative format pattern when available if (iconv_strpos($format, ';') !== false) { if (call_user_func(Zend_Locale_Math::$comp, $value, 0) < 0) { $format = iconv_substr($format, iconv_strpos($format, ';') + 1); } else { $format = iconv_substr($format, 0, iconv_strpos($format, ';')); } } if (strpos($format, '.')) { if (is_numeric($options['precision'])) { $value = Zend_Locale_Math::round($value, $options['precision']); } else { if (substr($format, strpos($format, '.') + 1, 3) == '###') { $options['precision'] = null; } else { $options['precision'] = strlen(substr($format, strpos($format, '.') + 1, strrpos($format, '0') - strpos($format, '.'))); $format = substr($format, 0, strpos($format, '.') + 1) . '###' . substr($format, strrpos($format, '0') + 1); } } } else { $value = Zend_Locale_Math::round($value, 0); $options['precision'] = 0; } $value = Zend_Locale_Math::normalize($value); } // get number parts if (strlen($value) != strlen(Zend_Locale_Math::round($value, 0))) { if ($options['precision'] === null) { $precstr = iconv_substr($value, strlen(Zend_Locale_Math::round($value, 0)) + 1); } else { $precstr = iconv_substr($value, strlen(Zend_Locale_Math::round($value, 0)) + 1, $options['precision']); if (iconv_strlen($precstr) < $options['precision']) { $precstr = $precstr . str_pad("0", ($options['precision'] - iconv_strlen($precstr)), "0"); } } } else { if ($options['precision'] > 0) { $precstr = str_pad("0", ($options['precision']), "0"); } } if ($options['precision'] === null) { if (isset($precstr)) { $options['precision'] = iconv_strlen($precstr); } else { $options['precision'] = 0; } } // get fraction and format lengths if (strpos($value, '.') !== false) { $number = substr((string) $value, 0, strpos($value, '.')); } else { $number = $value; } $prec = call_user_func(Zend_Locale_Math::$sub, $value, $number, $options['precision']); if (iconv_strpos($prec, '-') !== false) { $prec = iconv_substr($prec, 1); } if (($prec == 0) and ($options['precision'] > 0)) { $prec = "0.0"; } if (($options['precision'] + 2) > iconv_strlen($prec)) { $prec = str_pad((string) $prec, $options['precision'] + 2, "0", STR_PAD_RIGHT); } if (iconv_strpos($number, '-') !== false) { $number = iconv_substr($number, 1); } $group = iconv_strrpos($format, ','); $group2 = iconv_strpos ($format, ','); $point = iconv_strpos ($format, '0'); // Add fraction $rest = ""; if (($value < 0) && (strpos($format, '.'))) { $rest = substr(substr($format, strpos($format, '.') + 1), -1, 1); } if ($options['precision'] == '0') { $format = iconv_substr($format, 0, $point) . iconv_substr($format, iconv_strrpos($format, '#') + 2); } else { $format = iconv_substr($format, 0, $point) . $symbols['decimal'] . iconv_substr($prec, 2) . iconv_substr($format, iconv_strrpos($format, '#') + 2 + strlen($prec) - 2); } if (($value < 0) and ($rest != '0') and ($rest != '#')) { $format .= $rest; } // Add seperation if ($group == 0) { // no seperation $format = $number . iconv_substr($format, $point); } else if ($group == $group2) { // only 1 seperation $seperation = ($point - $group); for ($x = iconv_strlen($number); $x > $seperation; $x -= $seperation) { if (iconv_substr($number, 0, $x - $seperation) !== "") { $number = iconv_substr($number, 0, $x - $seperation) . $symbols['group'] . iconv_substr($number, $x - $seperation); } } $format = iconv_substr($format, 0, iconv_strpos($format, '#')) . $number . iconv_substr($format, $point); } else { // 2 seperations if (iconv_strlen($number) > ($point - $group)) { $seperation = ($point - $group); $number = iconv_substr($number, 0, iconv_strlen($number) - $seperation) . $symbols['group'] . iconv_substr($number, iconv_strlen($number) - $seperation); if ((iconv_strlen($number) - 1) > ($point - $group + 1)) { $seperation2 = ($group - $group2 - 1); for ($x = iconv_strlen($number) - $seperation2 - 2; $x > $seperation2; $x -= $seperation2) { $number = iconv_substr($number, 0, $x - $seperation2) . $symbols['group'] . iconv_substr($number, $x - $seperation2); } } } $format = iconv_substr($format, 0, iconv_strpos($format, '#')) . $number . iconv_substr($format, $point); } // set negative sign if (call_user_func(Zend_Locale_Math::$comp, $value, 0) < 0) { if (iconv_strpos($format, '-') === false) { $format = $symbols['minus'] . $format; } else { $format = str_replace('-', $symbols['minus'], $format); } } return (string) $format; }
/** * Returns a locale formatted number depending on the given options. * The seperation and fraction sign is used from the set locale. * ##0.# -> 12345.12345 -> 12345.12345 * ##0.00 -> 12345.12345 -> 12345.12 * ##,##0.00 -> 12345.12345 -> 12,345.12 * * @param string $input Localized number string * @param array $options Options: number_format, locale, precision. See {@link setOptions()} for details. * @return string locale formatted number */ public static function toNumber($value, array $options = array()) { print "\ntoNumber"; print "\n--------"; // load class within method for speed require_once 'Zend/Locale/Math.php'; $value = Zend_Locale_Math::normalize($value); print "\n1-Value :'" . $value . "'"; $options = array_merge(self::$_Options, self::checkOptions($options)); if ($options['locale'] instanceof Zend_Locale) { $options['locale'] = $options['locale']->toString(); } print "\n2-Locale:'" . $options['locale'] . "'"; // Get correct signs for this locale $symbols = Zend_Locale_Data::getList($options['locale'], 'symbols'); iconv_set_encoding('internal_encoding', 'UTF-8'); // Get format $format = $options['number_format']; print "\n3-Format1:'" . $format . "'"; if ($format === null) { $format = Zend_Locale_Data::getContent($options['locale'], 'decimalnumber'); print "\n3-Format2:'" . $format . "'"; if (iconv_strpos($format, ';') !== false) { if (call_user_func(Zend_Locale_Math::$comp, $value, 0) < 0) { $format = iconv_substr($format, iconv_strpos($format, ';') + 1); print "\n3-Format3:'" . $format . "'"; } else { $format = iconv_substr($format, 0, iconv_strpos($format, ';')); print "\n3-Format4:'" . $format . "'"; } } } else { print "\n3-Format5:'" . $format . "'"; // seperate negative format pattern when avaiable if (iconv_strpos($format, ';') !== false) { if (call_user_func(Zend_Locale_Math::$comp, $value, 0) < 0) { $format = iconv_substr($format, iconv_strpos($format, ';') + 1); print "\n3-Format6:'" . $format . "'"; } else { $format = iconv_substr($format, 0, iconv_strpos($format, ';')); print "\n3-Format7:'" . $format . "'"; } } if (strpos($format, '.')) { print "\n4-Prec:'" . $options['precision'] . "'"; if (is_numeric($options['precision'])) { $value = Zend_Locale_Math::round($value, $options['precision']); print "\n4-Value1:'" . $value . "'"; //print "\nSet Pr:'".$value."'"; } else { if (substr($format, strpos($format, '.') + 1, 3) == '###') { $options['precision'] = null; print "\n4-Value2"; } else { $options['precision'] = strlen(substr($format, strpos($format, '.') + 1, strrpos($format, '0') - strpos($format, '.'))); print "\n4-Prec3:'" . $options['precision'] . "'"; $format = substr($format, 0, strpos($format, '.') + 1) . '###' . substr($format, strrpos($format, '0') + 1); print "\n4-Format4:'" . $format . "'"; } } } else { $value = Zend_Locale_Math::round($value, 0); $options['precision'] = 0; print "\n4-Value5:'" . $value . "'"; } $value = Zend_Locale_Math::normalize($value); print "\n5-Value:'" . $value . "'"; } // get number parts if (strlen($value) != strlen(Zend_Locale_Math::round($value, 0))) { if ($options['precision'] === null) { $precstr = iconv_substr($value, strlen(Zend_Locale_Math::round($value, 0)) + 1); print "\n6-Prec1:'" . $precstr . "'"; } else { $precstr = iconv_substr($value, strlen(Zend_Locale_Math::round($value, 0)) + 1, $options['precision']); print "\n6-Prec2:'" . $precstr . "'"; if (iconv_strlen($precstr) < $options['precision']) { $precstr = $precstr . str_pad("0", $options['precision'] - iconv_strlen($precstr), "0"); print "\n6-Prec3:'" . $precstr . "'"; } } } else { print "\n6-Prec4"; if ($options['precision'] > 0) { $precstr = str_pad("0", $options['precision'], "0"); print "\n6-Prec5:'" . $precstr . "'"; } } if ($options['precision'] === null) { if (isset($precstr)) { $options['precision'] = iconv_strlen($precstr); print "\n7-Prec1:'" . $options['precision'] . "'"; } else { $options['precision'] = 0; print "\n7-Prec2:'" . $options['precision'] . "'"; } } // get fraction and format lengths if (strpos($value, '.') !== false) { $number = substr((string) $value, 0, strpos($value, '.')); print "\n8-Number1:'" . $number . "'"; } else { $number = $value; print "\n8-Number2:'" . $number . "'"; } $prec = call_user_func(Zend_Locale_Math::$sub, $value, $number, $options['precision']); print "\n9-Prec1:'" . $prec . "'"; if (iconv_strpos($prec, '-') !== false) { $prec = iconv_substr($prec, 1); print "\n9-Prec2:'" . $prec . "'"; } if ($prec == 0 and $options['precision'] > 0) { $prec = "0.0"; print "\n9-Prec3:'" . $prec . "'"; } if ($options['precision'] + 2 > iconv_strlen($prec)) { $prec = str_pad((string) $prec, $options['precision'] + 2, "0", STR_PAD_RIGHT); print "\n9-Prec4:'" . $prec . "'"; } if (iconv_strpos($number, '-') !== false) { $number = iconv_substr($number, 1); print "\n10-Number:'" . $number . "'"; } $group = iconv_strrpos($format, ','); $group2 = iconv_strpos($format, ','); $point = iconv_strpos($format, '0'); // Add fraction $rest = ""; if ($value < 0 && strpos($format, '.')) { $rest = substr(substr($format, strpos($format, '.') + 1), -1, 1); print "\n11-Rest:'" . $rest . "'"; } if ($options['precision'] == '0') { $format = iconv_substr($format, 0, $point) . iconv_substr($format, iconv_strrpos($format, '#') + 2); print "\n12-Format1:'" . $format . "'"; } else { $format = iconv_substr($format, 0, $point) . $symbols['decimal'] . iconv_substr($prec, 2) . iconv_substr($format, iconv_strrpos($format, '#') + 2 + strlen($prec) - 2); print "\n12-Format2:'" . $format . "'"; } if ($value < 0 and $rest != '0' and $rest != '#') { $format .= $rest; print "\n12-Format3:'" . $format . "'"; } // Add seperation if ($group == 0) { // no seperation $format = $number . iconv_substr($format, $point); print "\n12-Format4:'" . $format . "'"; } else { if ($group == $group2) { // only 1 seperation $seperation = $point - $group; for ($x = iconv_strlen($number); $x > $seperation; $x -= $seperation) { if (iconv_substr($number, 0, $x - $seperation) !== "") { $number = iconv_substr($number, 0, $x - $seperation) . $symbols['group'] . iconv_substr($number, $x - $seperation); print "\n12-Number5:'" . $number . "'"; } } $format = iconv_substr($format, 0, iconv_strpos($format, '#')) . $number . iconv_substr($format, $point); print "\n12-Format6:'" . $format . "'"; } else { // 2 seperations if (iconv_strlen($number) > $point - $group) { $seperation = $point - $group; $number = iconv_substr($number, 0, iconv_strlen($number) - $seperation) . $symbols['group'] . iconv_substr($number, iconv_strlen($number) - $seperation); print "\n13-Number1:'" . $number . "'"; if (iconv_strlen($number) - 1 > $point - $group + 1) { $seperation2 = $group - $group2 - 1; for ($x = iconv_strlen($number) - $seperation2 - 2; $x > $seperation2; $x -= $seperation2) { $number = iconv_substr($number, 0, $x - $seperation2) . $symbols['group'] . iconv_substr($number, $x - $seperation2); print "\n13-Number2:'" . $number . "'"; } } } $format = iconv_substr($format, 0, iconv_strpos($format, '#')) . $number . iconv_substr($format, $point); print "\n12-Format6:'" . $format . "'"; } } // set negative sign if (call_user_func(Zend_Locale_Math::$comp, $value, 0) < 0) { if (iconv_strpos($format, '-') === false) { $format = $symbols['minus'] . $format; } else { $format = str_replace('-', $symbols['minus'], $format); } } print "\nRESULT:'" . $format . "'"; return (string) $format; }