Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [PHP]Zamian polskich znaków
darektbg
post
Post #1





Grupa: Zarejestrowani
Postów: 54
Pomógł: 0
Dołączył: 25.09.2006

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


  1. <?php
  2. $short = htmlentities($_POST['short'], ENT_COMPAT, 'UTF-8');
  3.                    $short = trim($short);
  4.                    $short = addslashes($short);
  5.                    $short = strtolower($short);
  6.                    $short = strip_tags($short);
  7.                    $short = str_replace('ą', 'a', $short);
  8.                    $short = str_replace('ę', 'e', $short);
  9.                    $short = str_replace('ć', 's', $short);
  10.                    $short = str_replace('ż', 'z', $short);
  11.                    $short = str_replace('ź', 'z', $short);
  12.                    $short = str_replace('ś', 's', $short);
  13.                    $short = str_replace('ł', 'l', $short);
  14.                    $short = str_replace('ó', 'o', $short);
  15.                    $short = str_replace(' ', '-', $short);
  16. ?>

Kodowanie ustawione wszędzie na UTF-8. Efektem jednak są krzaki...
$_POST['short']=ąś => $short= ��
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi (1 - 2)
wookieb
post
Post #2





Grupa: Moderatorzy
Postów: 8 989
Pomógł: 1550
Dołączył: 8.08.2008
Skąd: Słupsk/Gdańsk




Zamień kolejnosc
  1. <?php
  2. $short=$_POST['short'];
  3.                   $short = str_replace('ą', 'a', $short);
  4.                   $short = str_replace('ę', 'e', $short);
  5.                   $short = str_replace('ć', 's', $short);
  6.                   $short = str_replace('ż', 'z', $short);
  7.                   $short = str_replace('ź', 'z', $short);
  8.                   $short = str_replace('ś', 's', $short);
  9.                   $short = str_replace('ł', 'l', $short);
  10.                   $short = str_replace('ó', 'o', $short);
  11.                   $short = str_replace(' ', '-', $short);
  12.                $short = htmlentities($short, ENT_COMPAT, 'UTF-8');
  13.                   $short = trim($short);
  14.                   $short = addslashes($short);
  15.                   $short = strtolower($short);
  16.                   $short = strip_tags($short);
  17. ?>


albo zamiast strtolower uzyj mb_strtolower

Ten post edytował wookieb 26.05.2009, 22:40:15
Go to the top of the page
+Quote Post
pgrzelka
post
Post #3





Grupa: Zarejestrowani
Postów: 313
Pomógł: 24
Dołączył: 9.08.2008
Skąd: Kielce

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


najpierw mb_strtolower a potem str_replace, bo duże litery Ci zostaną a zamienisz tylko małe
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: 23.08.2025 - 20:43