Skip to content

Output Configurations

You can apply additional configurations to control how numbers are formatted across your application. For example, if you want to display numbers with a specific number of decimal places, you can set this configuration in your provider or bootstrap file.

Configuration Example

Below is an example of how to configure decimal formatting:

php
use Serhii\ShortNumber\Number;
use Serhii\ShortNumber\Config;

Number::configure(new Config(decimals: 1, upperCase: true)); 

Once configured, all numbers will be formatted with the specified number of decimal places. For instance:

php
use Serhii\ShortNumber\Number;

echo Number::short(12_345); // output: "12.3K"

Available Configurations

Here is the full list of all available configurations for the latest version:

OptionTypeDefaultDescription
decimalsint0Number of decimals to show on the formatted number
decimalsSeparatorstring.Separator for the decimals
suffixSeparatorstringSeparator between the suffix and the number. Empty string by default
upperCaseboolfalseWhether to show the suffix in uppercase or not