'replace a text between tags in php
I have a php fine that output the html of a webpage.
The html is stored in a variable
$html = "<pre> something</pre> la la la <b> ohohoh </b> uuhhu <pre> ....";
Before doing an echo, I would like to add colors the C++ code between the pre tags.
I already have a function color($string) that does this, but I cannot do color($html) otherwise also the text outside pre tags will be parsed.
What I need to do is to scan the $html string and send to the color function only the part of the text between pre tags (there may be several pre /pre ) and replace it with the output of the function color().
how can i do this ?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
