tigiotoVast
New Member
given the following string in PHP:\[code\]$html = "<div><p><span class='test1 test2 test3'>text 1</span></p><p><span class='test1 test2'>text 2</span></p><p><span class='test1'>text 3</span></p><p><span class='test1 test3 test2'>text 4</span></p></div>";\[/code\]I just want to either empty or remove any class that has "test2" in it, so the result would be this:\[code\]<div><p><span class=''>text 1</span></p><p><span class=''>text 2</span></p><p><span class='test1'>text 3</span></p><p><span class=''>text 4</span></p></div>\[/code\]of if you're removing the element:\[code\]<div><p>text 1</p><p>text 2</p><p><span class='test1'>text 3</span></p><p>text 4</p></div>\[/code\]I'm happy to use a regex expression or something like PHP Simple HTML DOM Parser, but I have no clue how to use it. And with regex, I know how to find the element, but not the specific attribute associated w/ it, especially if there are multiple attributes like my example above. Any ideas?