number() public static method

Formats a string by number_format().
See also: http://www.php.net/manual/en/function.number-format.php
public static number ( string $value, array $format = [] ) : string
$value string Value
$format array Array with number of decimals, decimals point and thousands separator, default is `array(2, ',', ' ')`
return string
Esempio n. 1
0
 public function testNumber()
 {
     $value = 1336811080.23;
     $format = [];
     $this->assertEquals('1 336 811 080,23', rex_formatter::number($value, $format));
     $format = [5, ':', '`'];
     $this->assertEquals('1`336`811`080:23000', rex_formatter::number($value, $format));
 }
Esempio n. 2
0
 /**
  * Returns the formatted time difference.
  *
  * @param int $precision Factor which will be multiplied, for convertion into different units (e.g. 1000 for milli,...)
  * @param int $decimals  Number of decimals points
  *
  * @return string Formatted time difference
  */
 public function getFormattedDelta($precision = self::MILLISEC, $decimals = 3)
 {
     $time = $this->getDelta($precision);
     return rex_formatter::number($time, [$decimals]);
 }