aeroswat Posted December 8, 2009 Share Posted December 8, 2009 Is this the easiest way to filter a string to make it display only numbers? If so what would I use in this function? I'm not familiar with these expressions Quote Link to comment Share on other sites More sharing options...
aeroswat Posted December 8, 2009 Author Share Posted December 8, 2009 Would it be this? preg_replace(“/[^0-9]/”, “”, $string); Quote Link to comment Share on other sites More sharing options...
cags Posted December 8, 2009 Share Posted December 8, 2009 If the objective is to replace everything in a string that is not a number with nothing, then that pattern will work (though the intelligent quotes or whatever they are called will like cause problems). Quote Link to comment Share on other sites More sharing options...
nafetski Posted December 20, 2009 Share Posted December 20, 2009 \D will match all non numerics. preg_replace(“/\D/”, “”, $string); Shabow. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.