eevan79 Posted August 16, 2010 Share Posted August 16, 2010 It seems to preg_replace is advisableto use instead of ereg_replace. I'm not sure how to swap this simple code with preg_replace: $text = ereg_replace("[^0-9]", "", $text); Is this correct? $text = preg_replace("#[^0-9]#i", "", $text); Link to comment https://forums.phpfreaks.com/topic/210879-ereg_replace-to-preg_replace/ Share on other sites More sharing options...
cags Posted August 16, 2010 Share Posted August 16, 2010 Technically the exact translation of that code would be... $text = preg_replace("#[^0-9]#", "", $text); The i modifier makes the match case insensitive, which ereg_replace isn't (that's what eregi_replace was for). Having said that, it's purely academic since you have nothing in your pattern that would be affected by case sensitivity. Link to comment https://forums.phpfreaks.com/topic/210879-ereg_replace-to-preg_replace/#findComment-1099987 Share on other sites More sharing options...
.josh Posted August 17, 2010 Share Posted August 17, 2010 what, you mean there's no such thing as lowercase numbers? Link to comment https://forums.phpfreaks.com/topic/210879-ereg_replace-to-preg_replace/#findComment-1100103 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.