Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [PHP] Formatowanie liczb
ayo1001
post
Post #1





Grupa: Zarejestrowani
Postów: 74
Pomógł: 1
Dołączył: 29.03.2013

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


Witam,

Mam liczbę np. 2000
Jak zrobić warunek: jeżeli są 4 cyfry pokazuje: 2 tyś. ,jeżeli jest 5 (20 tyś), 6 (200 tyś), a jak jest 7 to pokazuje 2 mln. itd ?

Ten post edytował ayo1001 21.04.2015, 12:03:08
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi
ayo1001
post
Post #2





Grupa: Zarejestrowani
Postów: 74
Pomógł: 1
Dołączył: 29.03.2013

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


a jak dodać to do tego kodu ? (gdy mam już if/else) ?

  1. <?php
  2. $result = $a - $b;
  3.  
  4. if($result > 0){
  5. print "<div class='plus'>"; print $result; print "</div>";
  6. }
  7. else
  8. {
  9. print "<div class='minus'>"; print $result; print "</div>";
  10. }
  11.  
  12. ?>
Go to the top of the page
+Quote Post

Posty w temacie


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: 6.10.2025 - 21:48