1. The forums will be archived and moved to a read only mode in about 2 weeks (mid march).

Format currency 1K

Discussion in 'Help' started by Chisi, Jul 3, 2021.

  1. Chisi

    Chisi Spider

    Messages:
    6
    I want to ask has anyone made a money format plugin from $1000 to $1K and so on... where can i get it?
     
  2. xHearts

    xHearts Creeper

    Messages:
    2
    Answer taken from: https://stackoverflow.com/a/46421051
    Using this would be:

    PHP:
    public function number_format_short$n$precision ) {
        if (
    $n 900) {
            
    // 0 - 900
            
    $n_format number_format($n$precision);
            
    $suffix '';
        } else if (
    $n 900000) {
            
    // 0.9k-850k
            
    $n_format number_format($n 1000$precision);
            
    $suffix 'K';
        } else if (
    $n 900000000) {
            
    // 0.9m-850m
            
    $n_format number_format($n 1000000$precision);
            
    $suffix 'M';
        } else if (
    $n 900000000000) {
            
    // 0.9b-850b
            
    $n_format number_format($n 1000000000$precision);
            
    $suffix 'B';
        } else {
            
    // 0.9t+
            
    $n_format number_format($n 1000000000000$precision);
            
    $suffix 'T';
        }

    // HOW TO USE
    $number 1000;
    $this->number_format_short($number); // outputs 1K
     
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.