Jump to content

highlight attributes


The Little Guy

Recommended Posts

I am trying to highlight attributes in a html tag, for some reason, this just isn't working, does anyone know why?

 

$string = '
<a href="home.html" style="color:blue;">Home</a>
<p>Hello</p>
';
$att = '#ff0000';
preg_replace('~^\s([a-z].*?)\=~', '<span style="color:'.$att.'">$1</span>', $string);

 

Link to comment
https://forums.phpfreaks.com/topic/148191-highlight-attributes/
Share on other sites

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.