-
Notifications
You must be signed in to change notification settings - Fork 0
/
farsinum-core.php
26 lines (21 loc) · 980 Bytes
/
farsinum-core.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
<?php
/* Originally written by Farhadi , www.farhadi.ir */
function convertToFarsi($matches) {
$mps_jd_optionsDB = get_option(MPS_JD_OPTIONS_NAME);
$mps_jd_decimal = $mps_jd_optionsDB['mps_jd_decimal'];
if($mps_jd_decimal == true)
//$farsi_array = array("۰", "۱", "۲", "۳", "۴", "۵", "۶", "۷", "۸", "۹", "<sub><small>/</small></sub>");
$farsi_array = array("۰", "۱", "۲", "۳", "۴", "۵", "۶", "۷", "۸", "۹", "٫");
else
$farsi_array = array("۰", "۱", "۲", "۳", "۴", "۵", "۶", "۷", "۸", "۹", ".");
$english_array = array("0", "1", "2", "3", "4", "5", "6", "7", "8", "9", ".");
$out = '';
if (isset($matches[1])) {
return str_replace($english_array, $farsi_array, $matches[1]);
}
return $matches[0];
}
function farsi_num($num,$fake = null,$fake2=null) {
return preg_replace_callback('/(?:&#\d{2,4};)|(\d+[\.\d]*)|(?:[a-z](?:[\x00-\x3B\x3D-\x7F]|<\s*[^>]+>)*)|<\s*[^>]+>/i', 'convertToFarsi', $num);
}
?>