Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

 
Reply to this topicStart new topic
> [PHP]Zamiana środka numeru na *
KsaR
post
Post #1





Grupa: Zarejestrowani
Postów: 520
Pomógł: 102
Dołączył: 15.07.2014
Skąd: NULL

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


Istnieje jakaś gotowa wbudowana funkcja w php dzięki której osiągne cel?
(zamiany środka numeru na gwiazki),

na przykład: 123456 zamieni na 1****6.

Jeśli nie to dzięki którym funkcją dam radę to napisać (proszę o wskazówki).
Go to the top of the page
+Quote Post
Pyton_000
post
Post #2





Grupa: Zarejestrowani
Postów: 8 068
Pomógł: 1414
Dołączył: 26.10.2005

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


  1. substr_replace($string, '*', 1, strlen($string)-2);
Go to the top of the page
+Quote Post
KsaR
post
Post #3





Grupa: Zarejestrowani
Postów: 520
Pomógł: 102
Dołączył: 15.07.2014
Skąd: NULL

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


Cytat(Pyton_000 @ 15.07.2014, 16:48:51 ) *
  1. substr_replace($string, '*', 1, strlen($string)-2);


dalem $string = 12345678; i zwraca mi 1*8
Go to the top of the page
+Quote Post
Pyton_000
post
Post #4





Grupa: Zarejestrowani
Postów: 8 068
Pomógł: 1414
Dołączył: 26.10.2005

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



  1. substr_replace($string, str_repeat('*', strlen($string)-3), 1, strlen($string)-2);

Go to the top of the page
+Quote Post
KsaR
post
Post #5





Grupa: Zarejestrowani
Postów: 520
Pomógł: 102
Dołączył: 15.07.2014
Skąd: NULL

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


Cytat(Pyton_000 @ 15.07.2014, 16:57:27 ) *
  1. substr_replace($string, str_repeat('*', strlen($string)-3), 1, strlen($string)-2);


wszędzie o gwiazkę za mało

  1. <?php
  2. $string = 12345678; //1*****8
  3. echo substr_replace($string, str_repeat('*', strlen($string)-3), 1, strlen($string)-2);
  4. echo "<br>";
  5. $string=123; //13
  6. echo substr_replace($string, str_repeat('*', strlen($string)-3), 1, strlen($string)-2);
  7. echo "<br>";
  8. $string=123456; //1***6
  9. echo substr_replace($string, str_repeat('*', strlen($string)-3), 1, strlen($string)-2);
  10. ?>


Ten post edytował Ksar 15.07.2014, 16:09:46
Go to the top of the page
+Quote Post
viking
post
Post #6





Grupa: Zarejestrowani
Postów: 6 381
Pomógł: 1116
Dołączył: 30.08.2006

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


Zamień 3 na 2.
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: 17.10.2025 - 06:30