J.Silver Posted October 26, 2011 Share Posted October 26, 2011 I am writing an e-commerce website in multiple languages, including some eastern languages that have numerals in their languages different than the Arabic numerals used worldwide. To give an example: Arabic Numerals: 0 1 2 3,… Urdu Numerals: ٣ ٢ ١ ٠ In countries using such Urdu, Persian, etc. numbers PC keyboards are configured differently, some keyboards are configured to enter the Arabic numerals, while the majority of keyboards are configured to enter their native numbers. This invited a need to design my website so that credit card numbers, address and phone numbers can accept different forms of numerals. Since orders, users, … tables should have one form of numbers only, I am thinking of a script in which the user can enter credit card numbers, address and phone numbers in multiple form numbers and then all forms are translated in the tables to be in one form only, Arabic numerals. I would appreciate sharing any ideas, scripts, etc. to achieve this. Link to comment https://forums.phpfreaks.com/topic/249846-entering-numbers-in-different-formats/ Share on other sites More sharing options...
AyKay47 Posted October 26, 2011 Share Posted October 26, 2011 well the first thing that comes to my mind is to map the characters and use str_replace to convert them.. $map_arr = array("١ " => "a", "٢ " => "b"); $string = "text that you want to replace the characters in"; $string = str_replace(array_keys($map_array), array_values($map_arr),$string); if you will need to use this many times.. i would recommend storing it into a function.. Link to comment https://forums.phpfreaks.com/topic/249846-entering-numbers-in-different-formats/#findComment-1282412 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.