Post by suthi » Sun Sep 21, 2014 12:39 pm

How to add country code prefix to the telephone number?. Here is my code to prepend country code for Thailand so far:

For example, customer number is 0891234567, and I want to replace leading zero with +66 (66 = Thailand)

Code: Select all

$country_code = 66;
$phone_with_country_prefix = preg_replace('/^0?/', '+' . $country_code, $phone_without_country_prefix);
The code above return: +66891234567
Which is what I need, but I don't want to hard code the $country_code since I will be accepting orders from other countries as well. So, how do I accomplish this? How to get international dialing code from customer's address?

ของเล่นบทบาทสมมุติ
ของเล่นเสริมพัฒนาการ http://www.ubontown.com


User avatar
Newbie

Posts

Joined
Mon Jul 28, 2014 2:32 am
Who is online

Users browsing this forum: Bing [Bot] and 76 guests