Created
September 16, 2022 07:13
-
-
Save Semdevmaster/78820626acb48ff351fc7103bda1f21f to your computer and use it in GitHub Desktop.
ZoomX smarty modifier to format phone number
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 | |
/* | |
* Smarty plugin | |
* ------------------------------------------------------------- | |
* File: modifier.phone.php | |
* Type: modifier | |
* Name: phone | |
* Description: Format phone number. | |
* ------------------------------------------------------------- | |
*/ | |
function smarty_modifier_phone($phone) | |
{ | |
return preg_replace('/^\+(\d)(\d{3})(\d{3})(\d{2})(\d{2})$/', '8 (\2) \3-\4-\5', $phone); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment