Skip to content
Advertisement

PHP preg replace only allow numbers

How can I modify this existing preg_replace to only allow numbers?

JavaScript

Advertisement

Answer

I think you’re saying you want to remove all non-numeric characters. If so, D means “anything that isn’t a digit”:

JavaScript
User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement