You are here

function cmfcCalendarV1Iranian::convertNumbersToFarsi in Calendar Systems 8

Same name and namespace in other branches
  1. 8.2 calendar/v1/calendarSystems/iranian.class.inc.php \cmfcCalendarV1Iranian::convertNumbersToFarsi()
  2. 5 calendar/v1/calendarSystems/iranian.class.inc.php \cmfcCalendarV1Iranian::convertNumbersToFarsi()
  3. 6.3 calendar/v1/calendarSystems/iranian.class.inc.php \cmfcCalendarV1Iranian::convertNumbersToFarsi()
  4. 6 calendar/v1/calendarSystems/iranian.class.inc.php \cmfcCalendarV1Iranian::convertNumbersToFarsi()
  5. 7.3 calendar/v1/calendarSystems/iranian.class.inc.php \cmfcCalendarV1Iranian::convertNumbersToFarsi()
  6. 7 calendar/v1/calendarSystems/iranian.class.inc.php \cmfcCalendarV1Iranian::convertNumbersToFarsi()
  7. 7.2 calendar/v1/calendarSystems/iranian.class.inc.php \cmfcCalendarV1Iranian::convertNumbersToFarsi()

here convert to number in persian

File

calendar/v1/calendarSystems/iranian.class.inc.php, line 731

Class

cmfcCalendarV1Iranian

Code

function convertNumbersToFarsi($srting, $mode = 'html') {
  if ($mode == 'html') {
    $num0 = "۰";
    $num1 = "۱";
    $num2 = "۲";
    $num3 = "۳";
    $num4 = "۴";
    $num5 = "۵";
    $num6 = "۶";
    $num7 = "۷";
    $num8 = "۸";
    $num9 = "۹";
  }
  elseif ($mode == 'plainText') {
    $num0 = chr(hexdec('DB')) . chr(hexdec('B0'));
    $num1 = chr(hexdec('DB')) . chr(hexdec('B1'));
    $num2 = chr(hexdec('DB')) . chr(hexdec('B2'));
    $num3 = chr(hexdec('DB')) . chr(hexdec('B3'));
    $num4 = chr(hexdec('DB')) . chr(hexdec('B4'));
    $num5 = chr(hexdec('DB')) . chr(hexdec('B5'));
    $num6 = chr(hexdec('DB')) . chr(hexdec('B6'));
    $num7 = chr(hexdec('DB')) . chr(hexdec('B7'));
    $num8 = chr(hexdec('DB')) . chr(hexdec('B8'));
    $num9 = chr(hexdec('DB')) . chr(hexdec('B9'));
  }
  $stringtemp = "";
  $len = strlen($srting);
  for ($sub = 0; $sub < $len; $sub++) {
    if (substr($srting, $sub, 1) == "0") {
      $stringtemp .= $num0;
    }
    elseif (substr($srting, $sub, 1) == "1") {
      $stringtemp .= $num1;
    }
    elseif (substr($srting, $sub, 1) == "2") {
      $stringtemp .= $num2;
    }
    elseif (substr($srting, $sub, 1) == "3") {
      $stringtemp .= $num3;
    }
    elseif (substr($srting, $sub, 1) == "4") {
      $stringtemp .= $num4;
    }
    elseif (substr($srting, $sub, 1) == "5") {
      $stringtemp .= $num5;
    }
    elseif (substr($srting, $sub, 1) == "6") {
      $stringtemp .= $num6;
    }
    elseif (substr($srting, $sub, 1) == "7") {
      $stringtemp .= $num7;
    }
    elseif (substr($srting, $sub, 1) == "8") {
      $stringtemp .= $num8;
    }
    elseif (substr($srting, $sub, 1) == "9") {
      $stringtemp .= $num9;
    }
    else {
      $stringtemp .= substr($srting, $sub, 1);
    }
  }
  return $stringtemp;
}