質問

strlen showing wrong character when at the end of the title is ë its showing "�..."

The is my code:

<?php $title = the_title('', '', false); 
$title = (strlen($title)<60) ? $title : substr($title,0,50)."...";
echo $title;
<?php endforeach; ?>
役に立ちましたか?

解決

For unicode characters you need to use mb_strlen() and mb_substr()

Rewrite the above line to

$title = (mb_strlen($title,'utf-8')<60) ? $title : mb_substr($title,0,50,'utf-8')."...";
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top