For example, customer number is 0891234567, and I want to replace leading zero with +66 (66 = Thailand)
The code above return: +66891234567
Code: Select all
$country_code = 66; $phone_with_country_prefix = preg_replace('/^0?/', '+' . $country_code, $phone_without_country_prefix);
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?