PHP preg replace only allow numbers
I think you're saying you want to remove all non-numeric characters. If so, \D
means "anything that isn't a digit":
preg_replace('/\D/', '', $c)
Try this:
return preg_replace("/[^0-9]/", "",$c);
I think you're saying you want to remove all non-numeric characters. If so, \D
means "anything that isn't a digit":
preg_replace('/\D/', '', $c)
Try this:
return preg_replace("/[^0-9]/", "",$c);