Anonymní profil Mallcumek – Programujte.com
 x   TIP: Přetáhni ikonu na hlavní panel pro připnutí webu

Anonymní profil Mallcumek – Programujte.comAnonymní profil Mallcumek – Programujte.com

 

Příspěvky odeslané z IP adresy 90.181.152.–

Mallcumek
PHP › Hezké URL - problém s někter…
12. 8. 2021   #388386

#2 CZechBoY
Díky moc za kód. Přidal jsem nakonec funkci pro zmenšení velkých znaků. Možná to někdo řeší, já třeba nechci velká písmena v url.

$address = strtolower($address);

Výsledek je tedy :

<?php
$titulek="pšouček půjčka S -< Bobříkama kašička zpěvníček žabička řeřicha";
echo $titulek."<br><br>";

function prepis($retezec)
{
    $friendlyurl=Str_Replace(' ' ,'-',AddSlashes($retezec));
    $tbl = Array("\xc3\xa1"=>"a","\xc3\xa4"=>"a","\xc4\x8d"=>"c","\xc4\x8f"=>"d","\xc3\xa9"=>"e","\xc4\x9b"=>"e","\xc3\xad"=>"i","\xc4\xbe"=>"l","\xc4\xba"=>"l","\xc5\x88"=>"n","\xc3\xb3"=>"o","\xc3\xb6"=>"o","\xc5\x91"=>"o","\xc3\xb4"=>"o","\xc5\x99"=>"r","\xc5\x95"=>"r","\xc5\xa1"=>"s","\xc5\xa5"=>"t","\xc3\xba"=>"u","\xc5\xaf"=>"u","\xc3\xbc"=>"u","\xc5\xb1"=>"u","\xc3\xbd"=>"y","\xc5\xbe"=>"z","\xc3\x81"=>"A","\xc3\x84"=>"A","\xc4\x8c"=>"C","\xc4\x8e"=>"D","\xc3\x89"=>"E","\xc4\x9a"=>"E","\xc3\x8d"=>"I","\xc4\xbd"=>"L","\xc4\xb9"=>"L","\xc5\x87"=>"N","\xc3\x93"=>"O","\xc3\x96"=>"O","\xc5\x90"=>"O","\xc3\x94"=>"O","\xc5\x98"=>"R","\xc5\x94"=>"R","\xc5\xa0"=>"S","\xc5\xa4"=>"T","\xc3\x9a"=>"U","\xc5\xae"=>"U","\xc3\x9c"=>"U","\xc5\xb0"=>"U","\xc3\x9d"=>"Y","\xc5\xbd"=>"Z","'"=>"",",-"=>"kc");
    $url = StrTr($friendlyurl, $tbl);
    $address = StrTr ($url, "ÁÄČÇĎÉĚËÍŇÓÖŘŠŤÚŮÜÝŽáäčçďéěëíňóöřšťúůüýž ", "AACCDEEEINOORSTUUUYZaaccdeeeinoorstuuuyz-");
    $address = Preg_Replace ("/[^[:alpha:][:digit:]]/", "-", $address);
    $address = Trim ($address, "-");
    $address = Preg_Replace ("/[-]+/", "-", $address);
    $address = strtolower($address);
    return $address;
}
echo prepis($titulek);
?>

 

 

Hostujeme u Českého hostingu       ISSN 1801-1586       ⇡ Nahoru Webtea.cz logo © 20032024 Programujte.com
Zasadilo a pěstuje Webtea.cz, šéfredaktor Lukáš Churý