Link to home
Start Free TrialLog in
Avatar of seopti
seopti

asked on

Converting Phone Number

The phone numbers in my DB have this format:
(307)266-3290

I would like to convert them all to this format:
307-266-3290

I think I have to use SELECT CONCAT but not sure how to write the query or optionally just change the output in php.
ASKER CERTIFIED SOLUTION
Avatar of SStory
SStory
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Using php:

$number = "(307)266-3290";
$token = array("(", ")");
$replacement = array("", "-");
$number = str_replace($token, $replacement, $number);
echo $number;

Open in new window