Mega Code Archive

 
Categories / Php / Strings
 

E modifier treats the replacement string in preg_replace() as if it were PHP

<? function convDate( $month, $day, $year ) {   $year = ($year < 70 )?$year+2000:$year;   $time = ( mktime( 0,0,0,$month,$day,$year) );   return date("l d F Y", $time); } $dates = "3/18/03<br />\n7/22/04"; $dates = preg_replace( "/([0-9]+)\/([0-9]+)\/([0-9]+)/e","convDate($1,$2,$3)", $dates); print $dates; ?>