mkosmosports Posted April 4, 2007 Share Posted April 4, 2007 Hey, I have the following string: $test = "12/12/2007" What would be the most effective way of removing the forward slashes to come up with a "12122007" result? Thanks! Quote Link to comment Share on other sites More sharing options...
kenrbnsn Posted April 4, 2007 Share Posted April 4, 2007 Use the str_replace() function: <?php $test = "12/12/2007" $test = str_replace('/','',$test); echo $test; ?> You can also use a combination of date() and strtotime() <?php $test = "12/12/2007"; $test = date('mdY',strtotime($test)); echo $test; ?> Ken Quote Link to comment Share on other sites More sharing options...
mkosmosports Posted April 4, 2007 Author Share Posted April 4, 2007 Beautiful, much quicker than other options I had considered like trim or preg_replace..... Thanks! 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.