revraz Posted December 9, 2007 Share Posted December 9, 2007 Can I use a replace function to make this better? $rdate = "12/31/2007-14:00"; $rdate = str_replace ("-", "", $rdate); $rdate = str_replace ("/", "", $rdate); $rdate = str_replace (":", "", $rdate); echo $rdate; //123120071400 I basically want to strip everything non numeric and get a 12 digit number. Quote Link to comment Share on other sites More sharing options...
jcd Posted December 9, 2007 Share Posted December 9, 2007 $rdate = preg_replace('%\D%','',$rdate); Quote Link to comment Share on other sites More sharing options...
revraz Posted December 9, 2007 Author Share Posted December 9, 2007 Thanks a ton. I really need to learn more about regex, everytime I read how it works I get a headache. 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.