I have a string assigned to a variable of $output. I want to use QueryPath to iterate through the string and add a class to each matched element.
Currently I have:
$output = qp($output)->find('table')->addclass('table')->html();
The only issue with this is it removes the content of $output before the first match. Is there a way of using QueryPath to find the match and then add the class while keeping the contents of $output intact?
EDIT:
Pseudo code:
$output = '<table class="temp"><blah></blah></table>';
Magic QueryPath
$output = '<table class="temp blah"><blah></blah></table>';
try removing html()
For displaying: