Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> problem z zamiana znakow
wicc
post
Post #1





Grupa: Zarejestrowani
Postów: 18
Pomógł: 0
Dołączył: 30.07.2007

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


Chce zamienic znaki diaktryczne za pomoca polecenia preg_replace w funkcji:

  1. <?
  2. function noPl($str) {
  3. $patterns[0] = '/ą/';
  4. $patterns[1] = '/Ą/';
  5. $patterns[2] = '/ć/';
  6. $patterns[3] = '/Ć/';
  7. $patterns[4] = '/ę/';
  8. $patterns[5] = '/Ę/';
  9. $patterns[6] = '/ł/';
  10. $patterns[7] = '/Ł/';
  11. $patterns[8] = '/ó/';
  12. $patterns[9] = '/Ó/';
  13. $patterns[10] = '/ń/';
  14. $patterns[11] = '/Ń/';
  15. $patterns[12] = '/ś/';
  16. $patterns[13] = '/Ś/';
  17. $patterns[14] = '/ż/';
  18. $patterns[15] = '/Ż/';
  19. $patterns[16] = '/ź/';
  20. $patterns[17] = '/Ź/';
  21. $replacements[0] = 'a';
  22. $replacements[1] = 'A';
  23. $replacements[2] = 'c';
  24. $replacements[3] = 'C';
  25. $replacements[4] = 'e';
  26. $replacements[5] = 'E';
  27. $replacements[6] = 'l';
  28. $replacements[7] = 'L';
  29. $replacements[8] = 'o';
  30. $replacements[9] = 'O';
  31. $replacements[10] = 'n';
  32. $replacements[11] = 'N';
  33. $replacements[12] = 's';
  34. $replacements[13] = 'S';
  35. $replacements[14] = 'z';
  36. $replacements[15] = 'Z';
  37. $replacements[16] = 'z';
  38. $replacements[17] = 'Z';
  39.  
  40. return preg_replace($patterns, $replacements, $str);
  41. }
  42. ?>


nizej w kodzie wywoluje:

  1. <?
  2. echo $dozamiany=$_POST['nazwa'];
  3. echo noPl($dozamiany);
  4. ?>


i otrzymuje tekst niezmieniony... problem pojawia sie TYLKO kiedy do funkcji noPl przesylam noPl($...) a nie noPl("....")
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: 20.12.2025 - 16:39