In written Hebrew there are marks for vowels called niqqud instead of full letters. In English "a e i o u" are letters; in Hebrew they are marks under the letters. For example, in נִקּוּד there is a dot for "i" under the first letter (נִ) (Hebrew is read right-to-left). Each mark is a character but not a letter.
I am trying to get the last 2 letters (not characters) of any word in Hebrew. The problem is that the functions: substr()
and mb_substr()
include the vowel marker as a full character, and because of that it's not giving me the last 2 letters. What can I do?
Here is my code:
<?php
$array = array('סָאוּנְדּמֶן','לֵיְמֶן','דֹּמֶן','דּוֹרְמֶן','אחמד','בןהמלך');
$dynamicstring = 'שֶׁמֶן';
$word_strlen = strlen($dynamicstring);
$newstring = substr($dynamicstring, -4);
echo strlen($dynamicstring);
echo '<br>';
echo htmlspecialchars($newstring);
?>