PHP Using Back References With Preg_Replace() – String Function

 
//converts dates in dd/mm/yy format to mm/dd/yy format:<?
$test = "25/12/2000";
print preg_replace("|(\d+)/(\d+)/(\d+)|", "$2/$1/$3", $test);
?>

Enjoyed this post? Share it!

 

Leave a comment

Your email address will not be published.