troubleshooting Question

str_replace only between > & < symbols (the end and start-character of html-tags)

Avatar of eagle00789
eagle00789Flag for Netherlands asked on
Web Languages and StandardsWeb DevelopmentPHP
8 Comments1 Solution328 ViewsLast Modified:
I'm writing a plugin for Joomla that can replace abbrevs with abbrev tags and it's description (it uses span tags for Internet Explorer and the abbrev tags for FireFox). In the attached code snippet, you can see that i use str_replace for this purpose. Now i have ran into a small problem. 1 of my images name contains a word that is to be replaced by the str_replace function. If i let this happen, the image is not displayed anymore, as the file can't be found due to the wrong name thx to str_replace.
So what i basicly want is that str_replace only works between > and < character. Any clue how i can change my code snippet attached so that it only works between the above mentioned characters (or for that matter only outside ANY html tags??
<?php
        $style_cursor = $this->params->get('cursor','default');
        $style_border_width = $this->params->get('border-width','dashed');
        $style_border_style = $this->params->get('border-style','dashed');
        $style_border_color = $this->params->get('border-color','dashed');
        $style = "abbr, acronym, span.abbr {"
            . "\n cursor: ".$style_cursor.";"
            . "\n border-bottom: ".$style_border_width."px ".$style_border_style." ".$style_border_color.";"
            . "\n}";
        $document = &JFactory::getDocument();
        $document->addStyleDeclaration( $style );
        $abbrevs = $this->getAbbrev();
        $replacements = $this->createReplacements();
        $article->text = str_replace($abbrevs, $replacements, $article->text);
?>
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 8 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 8 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros