如何使用PHP GD库将阿拉伯语或波斯语字符写入图像?
即“احسان”
解决方法:
使用此函数将文本传递给imagettftext
<?php
function revUni($text) {
$wordsArray = explode(" ", $text);
$rtlCompleteText='';
for ($i = sizeOf($wordsArray); $i > -1; $i = $i-1) {
//$lettersArray = explode("|", str_replace(";|", ";", $wordsArray[$i]));
$lettersArray = explode(";", $wordsArray[$i]);
$rtlWord='';
for ($k = sizeOf($lettersArray); $k > -1; $k = $k-1) {
if (strlen($lettersArray[$k]) > 1) { // make sure its full unicode letter
$rtlWord = $rtlWord."".$lettersArray[$k].";";
}
}
$rtlCompleteText = $rtlCompleteText." ".$rtlWord;
}
return $rtlCompleteText;
}
?>