Skip to content

Instantly share code, notes, and snippets.

@Semdevmaster
Created September 16, 2022 07:13
Show Gist options
  • Save Semdevmaster/78820626acb48ff351fc7103bda1f21f to your computer and use it in GitHub Desktop.
Save Semdevmaster/78820626acb48ff351fc7103bda1f21f to your computer and use it in GitHub Desktop.
ZoomX smarty modifier to format phone number
<?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