1 Replies - 1454 Views - Last Post: 31 May 2011 - 02:04 AM

#1 noorahmad   User is offline

  • Untitled
  • member icon

Reputation: 209
  • View blog
  • Posts: 2,290
  • Joined: 12-March 09

US Number to Dari (Persian) Number

Posted 05 October 2009 - 04:15 AM

Description:
 "۰",
				1 => "۱",
				2 => "۲",
				3 => "۳",
				4 => "۴",
				5 => "۵",
				6 => "۶",
				7 => "۷",
				8 => "۸",
				9 => "۹"		
				);

$af_date = NULL;
$chars = preg_split('//', $num, -1, PREG_SPLIT_NO_EMPTY);
	foreach($chars as $key => $val){
	$af_num = NULL;		
		switch($val){
			case "0";
			$af_num = $AF[0];break;
			case "1":
			$af_num = $AF[1];break;
			case "2":
			$af_num = $AF[2];break;
			case "3":
			$af_num = $AF[3];break;
			case "4":
			$af_num = $AF[4];break;
			case "5":
			$af_num = $AF[5];break;
			case "6":
			$af_num = $AF[6];break;
			case "7":
			$af_num = $AF[7];break;
			case "8":
			$af_num = $AF[8];break;
			case "9":
			$af_num = $AF[9];break;
		}
		$af_date .=$af_num;
	}	
	return $af_date;
}
?>


Is This A Good Question/Topic? 0
  • +

Replies To: US Number to Dari (Persian) Number

#2 greatdragon2   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 18-May 09

Re: US Number to Dari (Persian) Number

Posted 31 May 2011 - 02:04 AM

Thanks for Sharing!
This function is much faster:
function Latin2FarsiNumbers($num){
$en_num = array ("1","2","3","4","5","6","7","8","9","0");
$fa_num = array ("۱","۲","۳","۴","۵","۶","۷","۸","۹","۰");
	return str_replace($en_num,$fa_num, $num);
}


Was This Post Helpful? 0
  • +
  • -

Page 1 of 1