我的数据库表位于utf8_general_ci
,网页标题定义为<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
我没有阅读整个单词的问题。 “Čovjek”等,但现在我需要使用函数来预测整个克罗地亚字母,我正在使用
$slova = iconv("UTF-8", "ASCII//TRANSLIT", $category['name']);
$firstLetter = substr(strtolower($slova), 0, 1);
结果我总是这样?每封克罗地亚信件
这是我的代码(foreach循环)
<?php $letter = 'prvo';
foreach ($categories as $category) :
$slova = iconv("UTF-8", "ASCII//TRANSLIT", $category['name']);
$firstLetter = substr(strtolower($slova), 0, 1);
if ($firstLetter !== $letter) :
if ($letter !== 'prvo') :
echo '</div>
<div class="col-sm-4 bottom-margine">';
endif;
$letter = $firstLetter;
if($firstLetter == 'Z'){
$firstLetter = $firstLetter.',Ž';
}
if($firstLetter == 'c'){
$firstLetter = $firstLetter.',Ć,Č';
}
if($firstLetter == 's'){
$firstLetter = $firstLetter.',Š';
}
else {
$firstLetter;
}
echo '<div class="index-font">'.strtoupper($firstLetter).'</div>';
endif;
echo '<div class="font-style"><a href="kategorije/'.$category['id'].'/'.$category['link'].'">'
.$category['name'].'
</a></div>';
endforeach; ?>