Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PHP

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);
}
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #convert #numbers #English #numbers #PHP
ADD COMMENT
Topic
Name
3+7 =