note 99316 modified in function.chunk-split by danbrown
| From: | danbrown@php.net | Date: | Tue, 10 Aug 2010 15:03:01 +0000 |
| Subject: | note 99316 modified in function.chunk-split by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-171523@lists.php.net to get a copy of this message | ||
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;
}
?>
--was--
If you are using UTF-8 charset you will face a problem with Arabic language
to solve this problem i used this function
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;
}
http://php.net/manual/en/function.chunk-split.php