Reputation: 41
I have an Arabic text and want to replace "Initial" & "Medial" forms of some letters (not all forms) with other letters or characters;
Example:
$text = '...وقد تم تصميم وبناء جميع مكونات الطائرة';
I need to replace the Initial form of letter "ت" which is in the word "تم" with another letter; available "ت" in "مكونات" that is the Final form of this letter shall not be replaced.
It seems character codes (Unicode) cannot be used in str_replace()
to find a specific form of a letter and replace it.
Note:
Most Arabic letters have different froms:
see wikipedia.org for more information.
Upvotes: 4
Views: 496
Reputation: 7408
Letter forms are used for output only. They shouldn't be stored and/or manipulated in this way. You should find another way to do what you want.
Try RegExp. This might help you. http://php.net/manual/en/regexp.reference.unicode.php
Or, if you insist on using str_replace
, you can do this.
str_replace(
' ت',
' وت',
$string
);
Upvotes: -1
Reputation: 53
Here i have given piece of code..hope will work for you$text = '...وقد تم تصميم وبناء جميع مكونات الطائرة';
$a=array('ت','تم');
$b=array('ت','مكونات');``
echo str_replace($a,$b,$text);
Upvotes: 0