I have date in following format 07 Dec, 2010. I need to convert it to 07_Dec_2010.
How can I achieve following using single statement
Help appreciated
Thanks
$newString = preg_replace('/\W+/', '_', $oldString);
This will replace any one or more non-word characters with a single underscore
$newdate = preg_replace('/[ ,]+/', '_', '07 Dec, 2010');
$newdate = str_replace( ' ', '_', str_replace( ',','', "07 Dec, 2010" ) );
Edit:
$newdate = str_replace( array(',' , ' '), array('' , '_'), "07 Dec, 2010" );