Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

 
Reply to this topicStart new topic
> zmiana formatu liczby
patrykt
post
Post #1





Grupa: Zarejestrowani
Postów: 101
Pomógł: 0
Dołączył: 3.12.2005

Ostrzeżenie: (0%)
-----


nazwa tematu może durna ale sens dość prosty:
muszę string "1362.00" zamienić na postać "1 362,00".
Go to the top of the page
+Quote Post
mike
post
Post #2





Grupa: Przyjaciele php.pl
Postów: 7 494
Pomógł: 302
Dołączył: 31.03.2004

Ostrzeżenie: (0%)
-----


Kod
function number_format( number, decimals, dec_point, thousand_sep, p ) {
    var n = ( '' + ( Math.round( number * ( p = Math.pow( 10, decimals || 0 ) ) ) / p ) ).split( '.' );

    for(var i = ( n[ 0 ] = n[ 0 ].split( '' ) ).length - 3; i>0; i-=3 ) {
        n[ 0 ].splice( i, 0, thousand_sep );
    }

    return n[ 0 ].join( '' ) + ( n[ 1 ] ? ( dec_point || ',') + n[ 1 ] : '');
}
Go to the top of the page
+Quote Post
patrykt
post
Post #3





Grupa: Zarejestrowani
Postów: 101
Pomógł: 0
Dołączył: 3.12.2005

Ostrzeżenie: (0%)
-----


wielkie dzięki
Go to the top of the page
+Quote Post

Reply to this topicStart new topic
2 Użytkowników czyta ten temat (2 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 14.10.2025 - 02:41