header("Content-Type: text/html; charset=UTF-8");
function wordwrap_utf8($str, $len)
{
preg_match_all('/[\xE0-\xFF][\x80-\xFF]{2}|./', $str, $match);
$finalStr = ' ';
$m = $match[0];
$ret = array();
$Total_Length = count($match[0]);
$flag1 = 1;
$flag2 = true;
for($j=0; $j < $Total_Length; $j++)
{
$ret[] = $m[$j];
if( $flag1 == $len )
{
$finalStr .= join('', $ret)."
";
$ret = array();
$flag1 = 1;
$flag2 = false;
}
else if( ( $j == $Total_Length-1 ) && ( $flag2 ) )
{
$finalStr .= join('', $ret)."
";
}
else
{
$flag1 = $flag1+1;
$flag2 = true;
}
}
return $finalStr;
}
$str ="aaaaaaaadsfdsffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffdsfghgfhgggggggggggggffffffffffffffdddddddddddddaaaaaaaadsfdsffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffdsfghgfhgggggggggggggffffffffffffffdddddddddddddaaaaaaaadsfdsffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffdsfghgfhgggggggggggggffffffffffffffdddddddddddddaaaaaaaadsfdsffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffdsfghgfhgggggggggggggffffffffffffffdddddddddddddaaaaaaaadsfdsffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffdsfghgfhgggggggggggggffffffffffffffdddddddddddddaaaaaaaadsfdsffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffdsfghgfhgggggggggggggffffffffffffffddddddddddddd";
$str = 'ㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹ';
$width = 10;
$test1 = wordwrap_utf8($str, $width);
echo $test1;
?>
function wordwrap_utf8($str, $len)
{
preg_match_all('/[\xE0-\xFF][\x80-\xFF]{2}|./', $str, $match);
$finalStr = ' ';
$m = $match[0];
$ret = array();
$Total_Length = count($match[0]);
$flag1 = 1;
$flag2 = true;
for($j=0; $j < $Total_Length; $j++)
{
$ret[] = $m[$j];
if( $flag1 == $len )
{
$finalStr .= join('', $ret)."
";
$ret = array();
$flag1 = 1;
$flag2 = false;
}
else if( ( $j == $Total_Length-1 ) && ( $flag2 ) )
{
$finalStr .= join('', $ret)."
";
}
else
{
$flag1 = $flag1+1;
$flag2 = true;
}
}
return $finalStr;
}
$str ="aaaaaaaadsfdsffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffdsfghgfhgggggggggggggffffffffffffffdddddddddddddaaaaaaaadsfdsffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffdsfghgfhgggggggggggggffffffffffffffdddddddddddddaaaaaaaadsfdsffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffdsfghgfhgggggggggggggffffffffffffffdddddddddddddaaaaaaaadsfdsffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffdsfghgfhgggggggggggggffffffffffffffdddddddddddddaaaaaaaadsfdsffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffdsfghgfhgggggggggggggffffffffffffffdddddddddddddaaaaaaaadsfdsffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffdsfghgfhgggggggggggggffffffffffffffddddddddddddd";
$str = 'ㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹㄹ';
$width = 10;
$test1 = wordwrap_utf8($str, $width);
echo $test1;
?>
No comments:
Post a Comment