Tā kā @pankijs nav onlainā gribēju pajautāt, kāds var padalīties ar koda rindiņu, lai links izskatītos šitā - https://kandrejevs.com/blog/read/29/testing-retina-display-to-its-limits
t.i. aizvācot visu, kas nav burti, un atstarpju vietā iesitot -.
SJohnson miniblogs
- 0
SJohnson 28.01.2014. 14:04
- 0
No exa:
function mkslug($string, $lower = true, $remove_dashes = true) {
$translit = array(
'/ä|æ|ǽ/' => 'ae',
'/ö|œ/' => 'oe',
'/ü/' => 'ue',
'/Ä/' => 'Ae',
'/Ü/' => 'Ue',
'/Ö/' => 'Oe',
'/À|Á|Â|Ã|Ä|Å|Ǻ|Ā|Ă|Ą|Ǎ|А/' => 'A',
'/à|á|â|ã|å|ǻ|ā|ă|ą|ǎ|ª|а/' => 'a',
'/б/' => 'Б',
'/б/' => 'b',
'/Ç|Ć|Ĉ|Ċ|Č|Ц|Ч/' => 'C',
'/ç|ć|ĉ|ċ|č|ц|ч/' => 'c',
'/Ð|Ď|Đ|Д/' => 'D',
'/ð|ď|đ|д/' => 'd',
'/È|É|Ê|Ë|Ē|Ĕ|Ė|Ę|Ě|Ё|Е|З|Э/' => 'E',
'/è|é|ê|ë|ē|ĕ|ė|ę|ě|ё|е|з|э/' => 'e',
'/Ф/' => 'F',
'/ф/' => 'f',
'/Ĝ|Ğ|Ġ|Ģ|Г/' => 'G',
'/ĝ|ğ|ġ|ģ|г/' => 'g',
'/Ĥ|Ħ|Х/' => 'H',
'/ĥ|ħ|х/' => 'h',
'/Ì|Í|Î|Ï|Ĩ|Ī|Ĭ|Ǐ|Į|İ|И|Й|Ы/' => 'I',
'/ì|í|î|ï|ĩ|ī|ĭ|ǐ|į|ı|и|й|ы/' => 'i',
'/Ĵ|Ъ/' => 'J',
'/ĵ|ъ/' => 'j',
'/Ķ|К/' => 'K',
'/ķ|к/' => 'k',
'/Ĺ|Ļ|Ľ|Ŀ|Ł|Л/' => 'L',
'/ĺ|ļ|ľ|ŀ|ł|л/' => 'l',
'/М/' => 'M',
'/м/' => 'm',
'/Ñ|Ń|Ņ|Ň|Н/' => 'N',
'/ñ|ń|ņ|ň|ʼn|н/' => 'n',
'/Ò|Ó|Ô|Õ|Ō|Ŏ|Ǒ|Ő|Ơ|Ø|Ǿ|О/' => 'O',
'/ò|ó|ô|õ|ō|ŏ|ǒ|ő|ơ|ø|ǿ|º|о/' => 'o',
'/П/' => 'P',
'/п/' => 'p',
'/Ŕ|Ŗ|Ř|Р/' => 'R',
'/ŕ|ŗ|ř|р/' => 'r',
'/Ś|Ŝ|Ş|Š|С|Ш|Щ/' => 'S',
'/ś|ŝ|ş|š|ſ|с|ш|щ/' => 's',
'/Ţ|Ť|Ŧ|Т/' => 'T',
'/ţ|ť|ŧ|т/' => 't',
'/Ù|Ú|Û|Ũ|Ū|Ŭ|Ů|Ű|Ų|Ư|Ǔ|Ǖ|Ǘ|Ǚ|Ǜ|У/' => 'U',
'/ù|ú|û|ũ|ū|ŭ|ů|ű|ų|ư|ǔ|ǖ|ǘ|ǚ|ǜ|у/' => 'u',
'/В/' => 'V',
'/в/' => 'v',
'/Ý|Ÿ|Ŷ/' => 'Y',
'/ý|ÿ|ŷ/' => 'y',
'/Ŵ/' => 'W',
'/ŵ/' => 'w',
'/Ź|Ż|Ž|Ж/' => 'Z',
'/ź|ż|ž|ж/' => 'z',
'/Æ|Ǽ/' => 'AE',
'/ß/' => 'ss',
'/IJ/' => 'IJ',
'/ij/' => 'ij',
'/Œ/' => 'OE',
'/ƒ/' => 'f',
'/Ю/' => 'Ju',
'/ю/' => 'ju',
'/Я/' => 'Ja',
'/я/' => 'ja'
);
$string = trim($string);
$string = preg_replace(array_keys($translit), array_values($translit), $string);
$string = str_replace('&', '-un-', $string);
$string = str_replace(array(' ', '.', ',', '"', '=', '`', ']', '[', '|', ':', '+', '"', '!', '/', "\\"), '-', $string);
$allowed = "/[^a-z0-9\\-\\_\\\\]/i";
$string = preg_replace($allowed, '', $string);
//remove repeated dashes
$string = preg_replace('/-+/', '-', $string);
//remove dashes from ends of string
if ($remove_dashes) {
$string = trim($string, '-');
}
$string = substr($string, 0, 100);
if (empty($string)) {
$string = 'page';
}
if ($lower) {
$string = strtolower($string);
}
return $string;
}
Ielogojies vai izveido profilu, lai komentētu!