I have a website in Persian. The keyboard of my website's users is in Persian (or Arabic) usually. So their password will not get matched sometimes.
I have a function for their username (cell-phone number) which converts Persian/Arabic digits to English:
function convert_digits_to_en($entry){
$fmt = numfmt_create('fa', NumberFormatter::DECIMAL);
return numfmt_parse($fmt, $entry);
}
It will work if the entry contains all digits.
i.e. ۰۹۱۲۳۵۶۵۴۹۸
will be converted to 09123565498
as well.
The problem is when the entry contains both characters and digits (like a password). i.e. test۰۹۱۲
. I need to convert it to test0912
. My current function returns an empty string for that entry. Any idea how can I fix it?