function convert($string) {
$persian = ['۰', '۱', '۲', '۳', '۴', '۵', '۶', '۷', '۸', '۹'];
$arabic = ['٩', '٨', '٧', '٦', '٥', '٤', '٣', '٢', '١','٠'];
$num = range(0, 9);
$convertedPersianNums = str_replace($persian, $num, $string);
$englishNumbersOnly = str_replace($arabic, $num, $convertedPersianNums);
return $englishNumbersOnly;
}
function convert2english($string) {
$newNumbers = range(0, 9);
// 1. Persian HTML decimal
$persianDecimal = array('۰', '۱', '۲', '۳', '۴', '۵', '۶', '۷', '۸', '۹');
// 2. Arabic HTML decimal
$arabicDecimal = array('٠', '١', '٢', '٣', '٤', '٥', '٦', '٧', '٨', '٩');
// 3. Arabic Numeric
$arabic = array('٠', '١', '٢', '٣', '٤', '٥', '٦', '٧', '٨', '٩');
// 4. Persian Numeric
$persian = array('۰', '۱', '۲', '۳', '۴', '۵', '۶', '۷', '۸', '۹');
$string = str_replace($persianDecimal, $newNumbers, $string);
$string = str_replace($arabicDecimal, $newNumbers, $string);
$string = str_replace($arabic, $newNumbers, $string);
return str_replace($persian, $newNumbers, $string);
}