preg_replace : preg_replace « String « PHP
- PHP
- String
- preg_replace
preg_replace
<?php
$text = "This is a link to http://www.java2s.com/.";
echo preg_replace("/http:\/\/(.*)\//", "<a href=\"\${0}\">\${0}</a>", $text);
?>
Related examples in the same category