Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [PHP] str_replace() nie działa w $_POST, przy zwykłych zmiennych śmiga normalnie
Manfred
post 1.04.2010, 12:12:01
Post #1





Grupa: Zarejestrowani
Postów: 45
Pomógł: 0
Dołączył: 21.03.2005
Skąd: Olsztyn

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


Witam.

Mam problem z funkcją str_replace(). Normalne zmienne $string działają (zamiana ó na o, spacje na "-" itp.), ale gdy chce tę funkcję wykorzystać do $_POST['string'] to w ogóle nie zamienia tych znaków, zostawia tak jak jest.

p1.php
  1. <form action="poligon.php" method="post">
  2. <p><label>Tytuł ogłoszenia:</label><input type="text" class="text-long" name="post" /></p>
  3. </form>


poligon.php
  1. <?php
  2.  
  3. function ogonki_Zamiana($text){
  4. $text=str_replace('ę', 'e', $text );
  5. $text=str_replace('ó', 'o', $text );
  6. $text=str_replace('ą', 'a', $text );
  7. $text=str_replace('ś', 's', $text );
  8. $text=str_replace('ł', 'l', $text );
  9. $text=str_replace('ż', 'z', $text );
  10. $text=str_replace('ź', 'z', $text );
  11. $text=str_replace('ń', 'n', $text );
  12. $text=str_replace('ć', 'c', $text );
  13. $text=str_replace('!', '', $text );
  14. $text=str_replace('?', '', $text );
  15. $text=str_replace('*', '', $text );
  16. $text=str_replace('"', '', $text );
  17. $text=str_replace('<', '', $text );
  18. $text=str_replace('>', '', $text );
  19. $text=str_replace(')', '', $text );
  20. $text=str_replace('(', '', $text );
  21. $text=str_replace('!', '', $text );
  22. $text=str_replace('=', '', $text );
  23. $text=str_replace('+', '', $text );
  24. $text=str_replace('-', ' ', $text );
  25. $text=str_replace(';', '', $text );
  26. $text=str_replace(':', '', $text );
  27. $text=str_replace(',', '', $text );
  28. $text=str_replace('.', '', $text );
  29. $text=str_replace('_', '-', $text );
  30. $text=str_replace('{', '', $text );
  31. $text=str_replace('}', '', $text );
  32. $text=str_replace(']', '', $text );
  33. $text=str_replace('|', '', $text );
  34. return $text;}
  35.  
  36. $zmienna = "łść";
  37. $zmienna = ogonki_Zamiana($zmienna);
  38.  
  39. echo "Zwykla zmienna: " . $zmienna;
  40. echo "<br />";
  41. echo "<br />";
  42.  
  43. $post = $_POST['post'];
  44. $post = ogonki_Zamiana($post);
  45. echo "Post: " . $_POST['post']; // tu nic się nie zmienia, a teoretycznie powinno
  46. echo "<br />";
  47.  
  48. ?>
Go to the top of the page
+Quote Post

Posty w temacie


Reply to this 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: 24.07.2025 - 20:01