Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PHP

Convert Persian, Arabic, Persian Decimal, Arabic Decimal To English Numbers PHP

//Convert Persian Arabic Persian Decimal & Arabic Decimal To English Numbers
function convert2englishNums($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);
}
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #Convert #Persian #Arabic #Decimal #To #English #Numbers #PHP
ADD COMMENT
Topic
Name
2+3 =