<?php

$phoneNumber = $order->XXXXXXXXX;
$phoneCharacter = array('-','(',')',' ');
$phonePrint = str_replace($phoneCharacter,'', $phoneNumber);

if (strlen($phonePrint) > '10' ) {
echo substr($phonePrint, 0, 1)."(".substr($phonePrint, 1, 3).") ".substr($phonePrint, 4, 3)."-".substr($phonePrint,7);
} else {
echo "(".substr($phonePrint, 0, 3).") ".substr($phonePrint, 3, 3)."-".substr($phonePrint,6);
}

?>

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.