Replace and Format text between tags.
Posted: Fri Aug 26, 2005 10:46 pm
I have this function:
What it does is take out the < code > tags and wrap their contents on a < div > tag.
What I want to do is get the content between the < code > tags, run in through a function, and replace the old text with it.
For example, lets say I have this string:
It should give out:
Now, lets say I want all of the text inside the < code > tags to run through the html2unicode($string) function before I place it back on the main string, how would I go about doing that?
Thank you very much in advance,
apg88
Code: Select all
function parseCode($input)
{
$rules = array("#\<code\>(.*?)\</code\>#si");
$changeto = array("<br>Code:<br>\n<div style=\"border: 1px solid black; background: #9cdff1\">\\1</div>");
$input = preg_replace($rules,$changeto,$input);
return $input;
}What I want to do is get the content between the < code > tags, run in through a function, and replace the old text with it.
For example, lets say I have this string:
Code: Select all
<code>this is the text inside of code</code>
this is not
<code> and yet again, this is inside code again, again</code>
now its notCode: Select all
<br>Code:<br>
<div style="border: 1px solid black; background: #9cdff1">this is the text inside of code<div>
this is not
<br>Code:<br>
<div style="border: 1px solid black; background: #9cdff1">and yet again, this is inside code again, again<div>
now its notThank you very much in advance,
apg88