Jump to content

Add style color to links?


Athens_demon

Recommended Posts

Hi there!,

 

I am trying to figure out how to use preg_replace or preg_match. I want to search a text block and add a color style to all the links. How is this possible?

 

Logical Example:

Search - > "<a href="whatever.php?id=123&sid=2312">" 
and replace with 

<a href="whatever.php?id=123&sid=2312" style="color: rgb(255, 250, 255);">

Link to comment
https://forums.phpfreaks.com/topic/232771-add-style-color-to-links/
Share on other sites

Not tested, but...

 

$buffer = preg_replace("#\<a href=\"([^\"]*)\"#", '<a href="$1" style="color: rgb(0, 0, 0)"', $buffer);

 

Basically, you're finding the opening a tag then replacing it with a new one with color in it. As long as all your links have the href attribute first, it should work on all if them, even with titles.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.