Indian numerals converter

5:42 AM

(1) Comments


hi all
i was building a project and i wanted to display the numbers on the browsers in many unicode forms
like Indian numerals or Hindu or even Thai numerals but i couldnt do that through simple output unicode on the browser and when i digit i found that the best way to do so is to convert each number into unicode html entity
and i build a simple tool to do that with php


here is the function i used to convert into indian numerals



function convertNum($str){
      $str = preg_replace('/([0-9])/','^\1^',$str);
      $enNum = array("^0^", "^1^", "^2^", "^3^", "^4^", "^5^","^6^","^7^","^8^", "^9^");
      $arNum = array("&# x0660;", "&# x0661;", "&# x0662;", "&# x0663;","&# x0664;", "&# x0665;", "&# x0666;", "&# x0667;", "&# x0668;", "&# x0669;");
   $str = str_replace($enNum, $arNum, $str);
   return $str;
 }


i used the html unicode entitiy for indian numerals from &# x0660; ; to &# x0660; ;

note: i put a space between &# and x to display the code correctly remove the spaces
you can modify the code as you wish
best regards

eslam

,

1 Response to "Indian numerals converter"

Josh Gage said :
January 12, 2011 at 2:59 PM
Web Hosting Design has excellent customer service and very reasonable rates. I have never had any issues with them, and plan on keeping them as my web host for a very long time. My sales rep was great call at (800) 491-WEB1

Post a Comment