![]() |
![]() ![]() |
![]() |
![]()
Post
#1
|
|
Grupa: Zarejestrowani Postów: 10 Pomógł: 0 Dołączył: 25.12.2007 Ostrzeżenie: (0%) ![]() ![]() |
mam taka funkcje do zmiany tytulu danego artykulu na PERMALINKA. Czyli jesli jest tytuł "Zośka poszła spać" to zmmienia na zoska-poszla-spac. Problem tkwi w tym, że nie wiem jak zmienić litery ęśąć itp na esac itp . $result = preg_replace('/ś/', ' s', $result); nnie działa;/
public function getStrippedTitle() { $result = strtolower($this->getTitle()); // strip all non word chars $result = preg_replace('/\W/', ' ', $result); // replace all white space sections with a dash $result = preg_replace('/\ +/', '-', $result); // trim dashes $result = preg_replace('/\-$/', '', $result); $result = preg_replace('/^\-/', '', $result); return $result; }
Powód edycji: dodałem tag (cysiaczek)
|
|
|
![]()
Post
#2
|
|
![]() Grupa: Zarejestrowani Postów: 1 657 Pomógł: 125 Dołączył: 29.04.2006 Ostrzeżenie: (0%) ![]() ![]() |
$result = str_replace('ś', 's', $result);
i tak z pozostałymi. btw. Jaki to ma związek z frameworkami? Ten post edytował radex_p 24.05.2008, 12:10:18 -------------------- |
|
|
![]()
Post
#3
|
|
Grupa: Zarejestrowani Postów: 10 Pomógł: 0 Dołączył: 25.12.2007 Ostrzeżenie: (0%) ![]() ![]() |
a to akurat z przykladu z tutoriala symfony, nie dziala, w pasku przegladarki wyskakuja krzaczki np %E% itp
|
|
|
![]()
Post
#4
|
|
![]() Grupa: Zarejestrowani Postów: 1 657 Pomógł: 125 Dołączył: 29.04.2006 Ostrzeżenie: (0%) ![]() ![]() |
działa, tylko źle to robisz.
Kod public function getStrippedTitle()
{ $result = strtolower($this->getTitle()); // strip all non word chars $result = preg_replace('/\W/', ' ', $result); // replace all white space sections with a dash $result = preg_replace('/\ +/', '-', $result); // trim dashes $result = preg_replace('/\-$/', '', $result); $result = preg_replace('/^\-/', '', $result); $result = str_replace('ś', 's', $result); $result = str_replace('ę', 'e', $result); $result = str_replace('ą', 'a', $result); // tutaj pozostałe pozamieniaj. return $result; } -------------------- |
|
|
![]()
Post
#5
|
|
Grupa: Zarejestrowani Postów: 10 Pomógł: 0 Dołączył: 25.12.2007 Ostrzeżenie: (0%) ![]() ![]() |
dziala ale jesli ta funkcje co zamienia znak np ś na dam na sam poczatek wtedy zamieni tylko ś, czyli
$result = str_replace('ś', 's', $result); $result = str_replace('ę', 'e', $result); to z wyrazu święty, zamieni tylko ś a ę bedzie krzeczkowate... znalazlem rozwiazanie: $polskie = array('ą','ć','ę','ł','ń','ó','ś','ź','ż','Ą','Ć','Ę','Ł','Ń','Ó','Ś','Ź','Ż'); $zmienione = array('a','c','e','l','n','o','s','z','z','A','C','E','L','N','O','S','Z','Z'); $result = str_replace($polskie, $zmienione, $result); tak zadziala prawidlowo pozdrawiam:) Ten post edytował bethebest 24.05.2008, 12:32:23 |
|
|
![]() ![]() |
![]() |
Aktualny czas: 21.08.2025 - 07:12 |