If you are using UTF-8 charset you will face a problem with Arabic language
to solve this problem i used this function
<?php
function chunk_split_($text,$length,$string_end)
{
$text = iconv("UTF-8","windows-1256",$text);
$text = str_split($text);
foreach($text as $val)
{
if($a !== $val)
{
$a = $val;
$x = 0;
}else{
$a = $val;
$x++;
}
if($x > $length)
{
$new_text .= $val.$string_end;
$x = 0;
}else
{
$new_text .= $val;
}
}
$new_text = iconv("windows-1256","UTF-8",$new_text);
return $new_text;
}
?>