Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

 
Closed TopicStart new topic
> [PHP]zamiana 1 na 01
orgazm666
post 6.10.2008, 16:31:10
Post #1





Grupa: Zarejestrowani
Postów: 5
Pomógł: 0
Dołączył: 6.10.2008

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


Siema. Jak w php zamienic liczby 0-9 na 01-09? prosze o pomoc, pozdrawiam goraco z Moskwy.

Ten post edytował batman 6.10.2008, 17:17:00
Powód edycji: dodałem tag do tematu oraz poprawiłem temat ~batman
Go to the top of the page
+Quote Post
phpion
post 6.10.2008, 16:32:24
Post #2





Grupa: Moderatorzy
Postów: 6 072
Pomógł: 861
Dołączył: 10.12.2003
Skąd: Dąbrowa Górnicza




sprintf" title="Zobacz w manualu PHP" target="_manual
Go to the top of the page
+Quote Post
orgazm666
post 6.10.2008, 16:37:49
Post #3





Grupa: Zarejestrowani
Postów: 5
Pomógł: 0
Dołączył: 6.10.2008

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


a dokladniej?
Go to the top of the page
+Quote Post
pyro
post 6.10.2008, 16:45:36
Post #4





Grupa: Zarejestrowani
Postów: 2 148
Pomógł: 230
Dołączył: 26.03.2008

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


mozesz tez uzyc str_replace jak i wielu innych sposobow


--------------------
ET LINGUA EIUS LOQUETUR IUDICIUM
Go to the top of the page
+Quote Post
orgazm666
post 6.10.2008, 16:48:03
Post #5





Grupa: Zarejestrowani
Postów: 5
Pomógł: 0
Dołączył: 6.10.2008

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


uzylem str_replace() ale zamienia mi tez 31 na 0301;/
Go to the top of the page
+Quote Post
owi
post 6.10.2008, 17:06:37
Post #6





Grupa: Zarejestrowani
Postów: 48
Pomógł: 2
Dołączył: 6.10.2008

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


to wstaw IF na poczatku


--------------------
eee yyy portfolio
Go to the top of the page
+Quote Post
orgazm666
post 6.10.2008, 17:11:59
Post #7





Grupa: Zarejestrowani
Postów: 5
Pomógł: 0
Dołączył: 6.10.2008

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


Kod
if($costam == '1') {

$costam = '01';

}



...




i tak mam pisac? a nie da sie jakos inaczej? oO

Pozdrowienia z Moskwy dla uzytkownikow php.pl

Ten post edytował orgazm666 6.10.2008, 17:12:16
Go to the top of the page
+Quote Post
batman
post 6.10.2008, 17:15:55
Post #8





Grupa: Moderatorzy
Postów: 2 921
Pomógł: 269
Dołączył: 11.08.2005
Skąd: 127.0.0.1




  1. <?php
  2. sprintf('%02d', $zmienna);
  3. ?>
To załatwi sprawę.

Przenoszę na przedszkole.


--------------------
I would love to change the world, but they won't give me the source code.
My software never has bugs. It just develops random features.
Go to the top of the page
+Quote Post
vokiel
post 8.10.2008, 09:26:02
Post #9





Grupa: Zarejestrowani
Postów: 2 592
Pomógł: 445
Dołączył: 12.03.2007

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


str_pad()


--------------------
Go to the top of the page
+Quote Post
Spirit86
post 8.10.2008, 10:45:28
Post #10





Grupa: Zarejestrowani
Postów: 607
Pomógł: 23
Dołączył: 8.09.2004
Skąd: Wrocław

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


  1. <?php
  2. $liczba = ($liczba<10) ? '0'.$liczba : $liczba;
  3. echo $liczba;
  4. ?>


--------------------
Audio: Metallica, Soil, RHCP, OffSpring, Green Day, "Retro", Gorillaz, Disturbed, Coma
DB: MySQL 4.1 | php: 4.4.3 Pomogłem Ci? Wciśnij przycisk POMÓGŁ.
Go to the top of the page
+Quote Post
drPayton
post 8.10.2008, 11:52:53
Post #11





Grupa: Zarejestrowani
Postów: 890
Pomógł: 65
Dołączył: 13.11.2005
Skąd: Olsztyn

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


Cytat(Spirit86 @ 8.10.2008, 11:45:28 ) *
  1. <?php
  2. $liczba = ($liczba<10) ? '0'.$liczba : $liczba;
  3. echo $liczba;
  4. ?>


I po co śmietnik robisz prezentując takie śmieci? Temat zakończony, sprintf lub str_pad z naciskiem na ten pierwszy... (Mamy wówczas liczbę, korzystając z str_pad - string...)
Go to the top of the page
+Quote Post
batman
post 8.10.2008, 12:01:06
Post #12





Grupa: Moderatorzy
Postów: 2 921
Pomógł: 269
Dołączył: 11.08.2005
Skąd: 127.0.0.1




Podano wiele rozwiązań problemu. By uniknąć bezsensownej dyskusji, zamykam temat.
Na prośbę autora otworzę.


--------------------
I would love to change the world, but they won't give me the source code.
My software never has bugs. It just develops random features.
Go to the top of the page
+Quote Post

Closed TopicStart new topic
1 Użytkowników czyta ten temat (1 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Wersja Lo-Fi Aktualny czas: 14.08.2025 - 08:32