Search code examples
phphtmlnumberscurrency

number_format every second number a img


I try to make a virutal money system and dont get the "number_format" I want it like the number "7951753" and want that output: 795 17 53

Other example: $money = 10001; 1 0 1

How I can make that?


Solution

  • You may use substr

    $mynumber=7951753;
    echo substr($mynumber, 0, 3)." Gold ". substr($mynumber, 3, 2)." Silver " . substr($mynumber, 5, 2)." Bronze ";
    

    above code produces output:-

    795 Gold 17 Silver 53 Bronze

    You may do same with 10001 to get 1 Gold 0 Silver 1 Bronze :)

    Have a try!