In PHP when I want to substr
the Persian string 'حروف فارسی برای امتحان', and it appends the question mark at the end of string.
This is my code:
$a = 'حروف فارسی برای امتحان'; echo substr($a,0,10);
And the problem is حروف �
Anyone has any suggestion or solution for this regards? much appreciated.
use mb_substr($a,0,10,'utf-8')
instead of substr() for Persian and Arabic characters
PHP does not have multi-byte character support by default. You have to use mb_* functions, like
mb_substr()