How i can add something after each URL ?! like replace <a href="http://website.com"> Text with something like <a href="http://website.com"> text Link to : http://website.com ?! my problem is that <a href="http://website.com"> can also be <a href="http://website.com class=link target_new , so it's a little bite hard to do it with explode then rebuild the html code, so i must to use some magic like preg replace
I try an code as: $website=" href=softgroups.com > caca maca /a ; href softgroups.com > softgroups /a "; $code="$1=<b>Link</b>"; $pattern='/\s(href)=["\']/i'; $website=preg_replace($pattern,$code,$website); but i want to add some text after the ending > so i don't known how to do it...
$text = preg_replace( '/<a([^>]+href=[\'"]?([^"\'\s]+)[^>]+)>(.*?)<\/a>/si', '<a$1>$3</a> <a href="http://website.com">Website</a>', $text ); PHP: If I understood you correctly.
Maybe this preg_replace php snippet will help you figure out what to do. <?php $link = '<a href="http://website.com">click here</a>'; $link = preg_replace('%<a href=(.*?)</a>%sim', '<a href=$1 Extra Text</a>', $link); echo $link; ?> PHP: