Parse Hyperlink

<?php
$line = '<a href="/users/adam">Edit profile</a>';
$converted_line = preg_replace('/<a[^>]*?href=['"](.*?)['"][^>]*?>(.*?)</a>/si','<a href="http://hyperspatial.com$1" target="_blank">$2</a>',$line);
echo $converted_line;
?>

0 Comments

You must be logged in to post a comment.