Last active
December 1, 2018 15:29
-
-
Save lawebfabric/8f0530ae2f62ce3f90769931a7d6c1b6 to your computer and use it in GitHub Desktop.
A simple snippet that return formated phone number for a html tag
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
//----------------------------------------------------------- | |
// formatPhone | |
//----------------------------------------------------------- | |
/* | |
* @author: Steeve from lawebfabric | |
* @website: http://www.lawebfabric.com | |
* @tutorial modx website: http://www.tutocms.fr/ | |
*/ | |
// $input = '04 94 39 28 49'; | |
// $input = '+33 4 56 78 98 76'; | |
// Return formated number like +33456789876 | |
$formated_number = preg_replace('/\s+/', '', $input); | |
$formated_number = preg_replace('/^0/','+33',$formated_number); | |
return $formated_number; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment