السلام عليكم،
لقد طورت هذه الدالة ولكنها لا تعمل بكفاءة الا مع النص اللاتيني وعكس ذلك مع النص العربي :
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-Transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>منطقة الادارة</title>
<link rel="stylesheet" href="css/admincp.css" type="text/css" />
</head>
<body>
<?php
$strg = "";
$txt = "السلام عليكم";
//$txt = "Welcome Abo Mohammed";
$lg_max = 10; //عدد الحروف المطلوبة
if (strlen($txt) > $lg_max)
{
$strg = mb_substr($txt, 0, $lg_max, "UTF-8"); echo "strg = ".$strg."<br />";
$last_space = strrpos($strg, " "); echo "last_space = ".$last_space."<br />";
if ($last_space !=0){$strg = mb_substr($strg, 0, $last_space,"UTF-8")."...";}
}
echo $strg;
?>
</body>
</html>لماذا هذا الفرق في النتيجة ؟
شكراً.