Ummed_Singh_Shekhawat Posted August 16, 2013 Share Posted August 16, 2013 how to validate european phone number?i will got mad plz help me to sort this one Link to comment https://forums.phpfreaks.com/topic/281237-how-to-validate-european-phone-number/ Share on other sites More sharing options...
darkfreaks Posted August 16, 2013 Share Posted August 16, 2013 Here's a simple function for formatting phone numbers with 7 to 10 digits in a more European (or Swedish?) manner: function formatPhone($num) { $num = preg_replace('/[^0-9]/', '', $num); $len = strlen($num); if($len == 7) $num = preg_replace('/([0-9]{2})([0-9]{2})([0-9]{3})/', '$1 $2 $3', $num); elseif($len == 8) $num = preg_replace('/([0-9]{3})([0-9]{2})([0-9]{3})/', '$1 - $2 $3', $num); elseif($len == 9) $num = preg_replace('/([0-9]{3})([0-9]{2})([0-9]{2})([0-9]{2})/', '$1 - $2 $3 $4', $num); elseif($len == 10) $num = preg_replace('/([0-9]{3})([0-9]{2})([0-9]{2})([0-9]{3})/', '$1 - $2 $3 $4', $num); return $num; } Link to comment https://forums.phpfreaks.com/topic/281237-how-to-validate-european-phone-number/#findComment-1445321 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.