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. Link to comment https://forums.phpfreaks.com/topic/80828-solved-can-i-use-regex-to-make-this-more-compact/ Share on other sites More sharing options...
jcd Posted December 9, 2007 Share Posted December 9, 2007 $rdate = preg_replace('%\D%','',$rdate); Link to comment https://forums.phpfreaks.com/topic/80828-solved-can-i-use-regex-to-make-this-more-compact/#findComment-410048 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. Link to comment https://forums.phpfreaks.com/topic/80828-solved-can-i-use-regex-to-make-this-more-compact/#findComment-410049 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.