Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [PHP]Problem z Polskimi znakami w str_replace, function friendly_seo_string
lukaszk
post
Post #1





Grupa: Zarejestrowani
Postów: 159
Pomógł: 0
Dołączył: 21.12.2010

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


Witam, mam problem z funkcją i nie wiem jak to przeskoczyć.
Poniższa funkcja zamienia znaki na inne mam problem z ą ę ś ć ź itd chcę aby zamieniała na a e .....
a obecnie niestety usuwa polskie znaki i zwraca wynik bez ładu i składu proszę o pomoc co muszę dopisać/zmienić w kodzie?
  1. <?php
  2. function friendly_seo_string($string, $separator = '-')
  3. {
  4. $string = trim($string);
  5.  
  6. $string = strtolower($string); // convert to lowercase text
  7.  
  8. $string = trim(ereg_replace("[^ A-Za-z0-9_]", " ", $string));
  9.  
  10.  
  11.  
  12. $string = ereg_replace("[ tnr]+", "-", $string);
  13.  
  14. $string = str_replace(" ", $separator, $string);
  15.  
  16. $string = ereg_replace("[ -]+", "-", $string);
  17.  
  18. return $string;
  19. }
  20. ?>


Ten post edytował lukaszk 5.04.2011, 15:00:11
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi
lukaszk
post
Post #2





Grupa: Zarejestrowani
Postów: 159
Pomógł: 0
Dołączył: 21.12.2010

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


Super pomogło dodaje z polskimi znakami a jak teraz poprawić kod aby te polskie znaki zostały zamienione z ą na a itd?
  1. <?php
  2. function friendly_seo_string($string, $separator = '-')
  3. {
  4. $string = trim($string);
  5.  
  6. $string = strtolower($string); // convert to lowercase text
  7.  
  8. $string = trim(preg_replace ("[^ A-Za-z0-9_]", " ", $string));
  9.  
  10.  
  11. $string = ereg_replace("[ tnr]+", "-", $string);
  12.  
  13. $string = str_replace(" ", $separator, $string);
  14.  
  15. $string = ereg_replace("[ -]+", "-", $string);
  16.  
  17. return $string;
  18. }
  19. ?>
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: 3.10.2025 - 09:23