yeahz Posted October 31, 2010 Report Share Posted October 31, 2010 $lv_burti = array("ē", "ŗ", "ū", "ī", "ō", "ā", "š", "ģ", "ķ", "ļ", "ž", "č", "ņ"); $eng_burti = array("e", "r", "u", "i", "o", "a", "s", "g", "k", "l", "z", "c", "n"); $title = str_replace($lv_burti, $eng_burti, $title); Tie burti netiek nomainīti no garumzīmjveidīgajiem pret bezgarumzīmjveidīgajiem. Kāpēc? Quote Link to comment Share on other sites More sharing options...
briedis Posted October 31, 2010 Report Share Posted October 31, 2010 (edited) Izmanto šo: function getSeo($str, $separator = '-'){ $str = iconv('UTF-8', 'ASCII//TRANSLIT//IGNORE', $str); $str = trim(preg_replace('/[^ A-Za-z0-9_-]/', ' ', $str)); return preg_replace('/[ -]+/', $separator, $str); } Hz, kas tev tur, bet man strādā: $lv_burti = array("ē", "ŗ", "ū", "ī", "ō", "ā", "š", "ģ", "ķ", "ļ", "ž", "č", "ņ"); $eng_burti = array("e", "r", "u", "i", "o", "a", "s", "g", "k", "l", "z", "c", "n"); echo str_replace($lv_burti, $eng_burti, "mārtiņš"); izvada: martins Faila kodējums ir UTF-8 (without BOM)? Edited October 31, 2010 by briedis Quote Link to comment Share on other sites More sharing options...
yeahz Posted October 31, 2010 Author Report Share Posted October 31, 2010 iconv arī negrib strādāt function fixlink($title){ $title = strtolower($title); $title = iconv('UTF-8', 'ASCII//TRANSLIT//IGNORE', $title); return $title; } vienkārši izvāc tos burtus, nevis nomaina. un faila kodējums ir UTF-8 without BOM. Quote Link to comment Share on other sites More sharing options...
yeahz Posted November 1, 2010 Author Report Share Posted November 1, 2010 (edited) hmmm kas nav riktīgi? kā funkcija nestrādā, bet kā ne-funkcija strādā. šis nestrādā function fixlink($title){ $title = strtolower($title); $lv_burti = array("ē", "ŗ", "ū", "ī", "ō", "ā", "š", "ģ", "ķ", "ļ", "ž", "č", "ņ"); $eng_burti = array("e", "r", "u", "i", "o", "a", "s", "g", "k", "l", "z", "c", "n"); $title = str_replace($lv_burti, $eng_burti, $title); return $title; } šis gan strādā $lv_burti = array("ē", "ŗ", "ū", "ī", "ō", "ā", "š", "ģ", "ķ", "ļ", "ž", "č", "ņ"); $eng_burti = array("e", "r", "u", "i", "o", "a", "s", "g", "k", "l", "z", "c", "n"); echo str_replace($lv_burti, $eng_burti, "mārtiņš"); funkcija izvada: m�rti�� ne-funkcija izvada: martins Edited November 1, 2010 by yeahz Quote Link to comment Share on other sites More sharing options...
xPtv45z Posted November 1, 2010 Report Share Posted November 1, 2010 Pieliec otram strtolower pirms tam un būs abiem vienādi. Quote Link to comment Share on other sites More sharing options...
briedis Posted November 1, 2010 Report Share Posted November 1, 2010 Pieliec otram strtolower pirms tam un būs abiem vienādi. mb_strtolower, starpcitu. Un kā ne/funkcija varianti ir vienā failā, vai dažādos? Es sliecos domāt, ka problēmas ir ar faila kodējumu... Quote Link to comment Share on other sites More sharing options...
yeahz Posted November 1, 2010 Author Report Share Posted November 1, 2010 tagad kad strtolower ir pēc arrayiem funkcijā, tad strādā, paldies. mb_strtolower, starpcitu. Un kā ne/funkcija varianti ir vienā failā, vai dažādos? Es sliecos domāt, ka problēmas ir ar faila kodējumu... ko mb_strtolower darīs savādāku nekā strtolower? skatījos arī php.net - izskatījās identiskas. iztestēju vienā failā ar kodējumu UTF-8 without BOM. Bet nu tagad strādā, kā gribēju. Quote Link to comment Share on other sites More sharing options...
rATRIJS Posted November 1, 2010 Report Share Posted November 1, 2010 http://www.php.net/manual/en/intro.mbstring.php Quote Link to comment Share on other sites More sharing options...
xPtv45z Posted November 1, 2010 Report Share Posted November 1, 2010 Uz "mĀrtiŅŠ" arī viss strādā kā vajag? Quote Link to comment Share on other sites More sharing options...
yeahz Posted November 1, 2010 Author Report Share Posted November 1, 2010 jā Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.