PHP\'s wordwrap() function doesn\'t work correctly for multi-byte strings like UTF-8.
There are a few examples of mb safe functions in the comments, but with some di
Just want to share some alternative I found on the net.
Using mb_str_split
, you can use join
to combine the words with
.
';
echo join('
', mb_str_split($text, 20));
And finally create your own helper, perhaps mb_textwrap
')
{
return join($concat, mb_str_split($text, $length));
}
}
$text = '';
// so simply call
echo mb_textwrap($text);
See screenshot demo: