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. $adres = 'www.strona.pl/to-jest-mój-artykuł';
  2.  
  3. $polskieLiterki = 'ążśźęćńółĄŻŚŹĘĆŃÓŁ';
  4. $odpowiedniki = 'azszecnolAZSZECNOL';
  5.  
  6. $adres = str_replace(str_split($polskieLiterki), str_split($odpowiedniki), $adres);
  7.  
  8. echo $adres; // www.strona.pl/to-jest-moj-artykul
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 - 04:50