CincoPistolero Posted January 8, 2009 Share Posted January 8, 2009 I have a form that asks for area code -111, and for phone number 999.1234 or 9991234 or 999-1234 and any other variation. What I'd like to do is take whatever they enter as a phone number and only send the numbers into the database - 9991234, that way I can use regular expressions when I pull it out to display it how I want. How do I go about stripping out the "." or "-" before inputting into db. Or is it easier to strip those out when I pull them from the db? Any direct code answers or links to pages containing tutorials or examples is much appreciated. Link to comment https://forums.phpfreaks.com/topic/140081-question-about-phone-numbers-in-forms/ Share on other sites More sharing options...
timmah1 Posted January 8, 2009 Share Posted January 8, 2009 I think this will work $phone = $_POST['phone']; $new_string = ereg_replace("[^0-9]", "", $phone); Link to comment https://forums.phpfreaks.com/topic/140081-question-about-phone-numbers-in-forms/#findComment-732902 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.