I am looking for a way to make sure when a phone number is added to the database for an order/customer that it is stripped of all non-numeric characters.
I have code to strip the characters and ensure it is all digits/numbers however I am not sure how I can make it hook in and do this right before saving to the database to make sure it gets saved as just numbers.
Any ideas on the best way to do this and how?
$str = '(760) 451-2832';
$phone = preg_replace("/[^a-zA-Z0-9]/", "", $str);