Pomoc - Szukaj - Użytkownicy - Kalendarz
Pełna wersja: [PHP]Zamian polskich znaków
Forum PHP.pl > Forum > PHP
darektbg
  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= ��
wookieb
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
pgrzelka
najpierw mb_strtolower a potem str_replace, bo duże litery Ci zostaną a zamienisz tylko małe
To jest wersja lo-fi głównej zawartości. Aby zobaczyć pełną wersję z większą zawartością, obrazkami i formatowaniem proszę kliknij tutaj.
Invision Power Board © 2001-2025 Invision Power Services, Inc.