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

PREVIOUS NEXT
Code Example
Php :: laravel new line in language file 
Php :: Fatal error: Composer detected issues in your platform: Your Composer dependencies require a PHP version "= 8.1.0". You are running 8.0.8. in /Applications/MAMP/htdocs/schools/vendor/composer/platform_check.php on line 24 
Php :: laravel collection pluck 
Php :: array filter multiple conditions php 
Php :: in_array 
Php :: php cmd shell 
Php :: how to remove keys in subarray php 
Php :: laravel storage 
Php :: php check if text is blank 
Php :: parse data from xml CDATA php 
Php :: Add WooCommerce Price Suffix 
Php :: php mongodb dll 
Php :: post params in body laravel 
Php :: bootstrap pagination laravel 
Php :: laravel-cors 
Php :: wp query meta in array 
Php :: php check if query succeeded 
Php :: laravel @extends 
Php :: pagination php mysql 
Php :: Malformed UTF-8 characters, possibly incorrectly encoded 
Php :: img src php wordpress theme child 
Php :: laravel update from 7 to 8 
Php :: filter child table data from parent laravel eloquent 
Php :: how to create shortcode with php 
Php :: wp_customize_image_control 
Php :: share wordpress post on whatsapp without plugin 
Php :: php array order alphabetically 
Php :: valid image extensions in php 
Php :: php array to array collection 
Php :: taxonomy_get_parents drupal 8 
ADD CONTENT
Topic
Content
Source link
Name
7+8 =