How can I split a string with accents in PHP? -
i split hurgarian strings have accents. use code:
if(strlen($row['title'])<=20) { echo $row['title']; } else { echo substr($row['title'], 0, 17)." ..."; }
i store these datas latin2_hungarian_ci coding in database , use charset in php files. both in php , html part:
header('content-type: text/html; charset=utf-8'); <meta http-equiv="content-type" content="text/html; charset=utf-8">
but way if last character non english character (é,á,ö,ü,ó,ő,ú,ű,í) isn't appears well. against character appears � simbol. if don't use substr write whole tite out everíthing works good.
now example: végzet erekly� ... or Északi széless� ...
i can't understand substr, because in examples 1 of them write 15 characters , simbol, other 1 16 characters , simbol.
how can write out first x characters of them?
use iconv function change charset latin2 utf-8 , make mb_substr
.
echo iconv("iso-8859-2","utf-8//translit", $string);
Comments
Post a Comment