Indian numerals converter
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
1 Response to "Indian numerals converter"
Post a Comment