Jump to content
php.lv forumi

Stringa (ar garumzīmēm) pārkonvertēšana


senters

Recommended Posts

Risinājums (ja nu kādam noder):

 

 

function url_friendly($text) {
   $url = strtolower($text);
   $utf = array('ā', 'ē', 'ī', 'ū', 'č', 'ģ', 'ķ', 'ļ', 'ņ', 'ŗ', 'š', 'ž', 'Ā', 'Ē', 'Ī', 'Ū', 'Č', 'Ģ', 'Ķ', 'Ļ', 'Ņ', 'Ŗ', 'Š', 'Ž');
   $ltn = array('a', 'e', 'i', 'u', 'c', 'g', 'k', 'l', 'n', 'r', 's', 'z', 'a', 'e', 'i', 'u', 'c', 'g', 'k', 'l', 'n', 'r', 's', 'z');
   $url = str_replace($utf, $ltn, $url);
   $url = preg_replace('/\s/', '-', $url);
   $url = preg_replace('/[^\w\-]/', '', $url);
   return $url;
}

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
×
×
  • Create New...