-
Notifications
You must be signed in to change notification settings - Fork 14
/
NumberTools.php
59 lines (55 loc) · 1012 Bytes
/
NumberTools.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
<?php
/**
* NumberTools Class
* Author Pouya Darabi
* Contact : [email protected]
*/
class NumberTools {
private static $persian_digits = array (
'۰',
'۱',
'۲',
'۳',
'۴',
'۵',
'۶',
'۷',
'۸',
'۹'
);
private static $arabic_digits = array (
'٠',
'١',
'٢',
'٣',
'٤',
'٥',
'٦',
'٧',
'٨',
'٩'
);
private static $english_digits = array (
'0',
'1',
'2',
'3',
'4',
'5',
'6',
'7',
'8',
'9'
);
public static function arabicPersionToEnglish($str) {
$str = str_replace ( self::$persian_digits, self::$english_digits, $str );
$str = str_replace ( self::$arabic_digits, self::$english_digits, $str );
return $str;
}
public static function EnglishToPersion($str) {
return str_replace ( self::$english_digits, self::$persian_digits, $str );
}
public static function EnglishToarabic($str) {
return str_replace ( self::$english_digits, self::$arabic_digits, $str );
}
}