Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [PHP] Zmiękczenia w url
-4in1-
post
Post #1





Goście







Witam, czy wie ktoś jak zrobić aby URL zamiast
www.strona.pl/to-jest-mój-artykuł,
wyświetlał:
www.strona.pl/to-jest-moj-artkul ?

Fragment kodu skryptu
  1. function generate_seo_link($input,$replace = '-',$remove_words = true,$words_array = array() )
  2. {
  3. //make it lowercase, remove punctuation, remove multiple/leading/ending spaces
  4. $return = trim(ereg_replace(' +',' ',preg_replace('/[^a-zA-Z0-9\sążśźćęłóńĄŻŚŹĆĘŃÓŁ]/','',strtolower($input))));
  5.  
  6. //remove words, if not helpful to seo
  7. //i like my defaults list in remove_words(), so I wont pass that array
  8. if($remove_words) { $return = remove_words($return,$replace,$words_array); }
  9.  
  10. //convert the spaces to whatever the user wants
  11. //usually a dash or underscore..
  12. //...then return the value.
  13. return str_replace(' ',$replace,$return);
  14. }


Znalazłem podpowiedzi typu http://blog.poradnik-webmastera.com/57/skr...-krzaczki-w-url, jednak nie wiem jak to wprowadzić w ten skrypt...
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi
Sephirus
post
Post #2





Grupa: Zarejestrowani
Postów: 1 527
Pomógł: 438
Dołączył: 28.06.2011
Skąd: Warszawa

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


  1. function generate_seo_link($input,$replace = '-',$remove_words = true,$words_array = array() )
  2. {
  3. // TUTAJ DODAJEMY
  4. $polskieLiterki = 'ążśźęćńółĄŻŚŹĘĆŃÓŁ';
  5. $odpowiedniki = 'azszecnolAZSZECNOL';
  6.  
  7. $input = str_replace(str_split($polskieLiterki), str_split($odpowiedniki), $input);
  8. // I MAŁA POPRAWKA PONIŻEJ
  9.  
  10.  
  11. //make it lowercase, remove punctuation, remove multiple/leading/ending spaces
  12. $return = trim(ereg_replace(' +',' ',preg_replace('/[^a-zA-Z0-9\s]/','',strtolower($input)))); // TU JUŻ USUWANIE POLSKICH LITEREK JEST ZBĘDNE
  13.  
  14. //remove words, if not helpful to seo
  15. //i like my defaults list in remove_words(), so I wont pass that array
  16. if($remove_words) { $return = remove_words($return,$replace,$words_array); }
  17.  
  18. //convert the spaces to whatever the user wants
  19. //usually a dash or underscore..
  20. //...then return the value.
  21. return str_replace(' ',$replace,$return);
  22. }
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: 14.10.2025 - 16:03