i need to split Arabic text am trying different methods but not solved it
$input = "ابجد";
$split = mb_str_split($input);
print_r($split);
am expected output like
(ا،ب،ج،د)
need solution
i need to split Arabic text am trying different methods but not solved it
$input = "ابجد";
$split = mb_str_split($input);
print_r($split);
am expected output like
(ا،ب،ج،د)
need solution
2
Answers
You can try mb_str_split() which can process multibyte strings. This code:
results in:
When you manipulate (trim, split, splice, etc.) strings encoded in a multibyte encoding, you need to use special functions since two or more consecutive bytes may represent a single character in such encoding schemes. Otherwise, if you apply a non-multibyte-aware string function to the string, it probably fails to detect the beginning or ending of the multibyte character and ends up with a corrupted garbage string that most likely loses its original meaning.
You can reverse the output by using array_reverse(), like this:
The output now is:
See: https://3v4l.org/ZsJNb
You can try
implode
for output=(ا،ب،ج،د) :