Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [PHP]Jak za pomocą str_replace usunąć wszystkie znaki jednoliterowe ?
Greg23
post
Post #1





Grupa: Zarejestrowani
Postów: 120
Pomógł: 0
Dołączył: 6.04.2012

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


$get = str_replace("-", "", $get);

Chciałbym to połączyć z strlen, tak aby wstawić to jako pierwszy parametr w str_replace i żeby usunęło mi wszystkie znaki jednoliterowe.
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi
Greg23
post
Post #2





Grupa: Zarejestrowani
Postów: 120
Pomógł: 0
Dołączył: 6.04.2012

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


X,y,z też mają być usunięte, próbowałem sposobem Damonssona, ale coś mi to nie działa w moim kodzie:

  1. if ($_GET['kategoria']=='2') {
  2.  
  3.  
  4. if ($_GET['co']) {
  5. $get = str_replace(" ", "+", $_GET['co']);
  6. $get = str_replace("-", "", $get);
  7. $get = str_replace("&", "", $get);
  8. $get = str_replace("%26", "", $get);
  9.  
  10. $pattern = '/\s[\S]{1}\s/i';
  11. $replacement = '';
  12. $get=preg_replace($pattern, $replacement, $get);
  13.  
  14.  
  15. $get=strtolower($get);
  16. }
  17.  
  18. header("Location: ../szukaj/" . $get . "");


W linku mam ciągle stringi jednoznakowe, nie są one usunięte :/
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: 9.10.2025 - 20:29