So i have this here
<? $regex = array('/@(\w+)/','/#(\w+)/','/((www|http:\/\/)[^ ]+)/');
$replace = array(
'<a href="https://www.twitter.com/$1">@$1</a>',
'<a href="https://twitter.com/#!/search/%23$1">#$1</a>',
'<a href="\1">\1</a>'
); ?>
<?= preg_replace($regex,$replace,stripslashes($row['tweet_text']));?>
The first two are suppose to turn anything with @ and # into links. This is obviously for twitter. But the third is supposed to turn anything with http or www into a link. But it seems to be conflicting with the first two messing up the links.
How can i make the third one make http or www links without conflicting the other two?
This is going to be hacky at best, but you could try this:
Turn the order around, fixing the links first, then only replace
@and#handles if they are not preceded by a>(which they would be if they were already inside an anchor tag).