Search
 
SCRIPT & CODE EXAMPLE
 

PHP

change arabic number to english php

function convert($string) {
    $persian = ['۰', '۱', '۲', '۳', '۴', '۵', '۶', '۷', '۸', '۹'];
    $arabic = ['٩', '٨', '٧', '٦', '٥', '٤', '٣', '٢', '١','٠'];

    $num = range(0, 9);
    $convertedPersianNums = str_replace($persian, $num, $string);
    $englishNumbersOnly = str_replace($arabic, $num, $convertedPersianNums);

    return $englishNumbersOnly;
}
Comment

convert Persian/Arabic numbers to English numbers PHP

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);
}
Comment

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);
}
Comment

PREVIOUS NEXT
Code Example
Php :: laravel test mail 
Php :: create model laravel 
Php :: connect sql server php 
Php :: how to download image from url from a particular div in php 
Php :: laravel model with migration 
Php :: laravel factory relationship one to many 
Php :: count with condition laravel 
Php :: specification migration laravel 
Php :: how to loop with while in php for array associative 
Php :: mail sending setting magneto for mailhog 
Php :: get value from url in laravel blade 
Php :: php order filename 
Php :: php regular expression function 
Php :: laravel maximum execution time of 30 seconds exceeded 
Php :: recursive binary search php 
Php :: laravel db table get one columns value 
Php :: php mod 
Php :: generate unique order id in php 
Php :: define constructor in trait php 
Php :: json stringify to php array 
Php :: laravel eloquent multiple join with where conditions 
Php :: composer dump autoload laravel 
Php :: multi theme laravel 
Php :: set only allow post request to a page - php 
Php :: array to string conversion php 
Php :: laravel trim string blade 
Php :: laravel blade @auth 
Php :: - in php 
Php :: php get current page url 
Php :: how to add column to database in laravel 
ADD CONTENT
Topic
Content
Source link
Name
5+9 =