Finding and Replacing text within Span Tags
Posted: Wed Mar 09, 2005 12:29 am
I'm sorry if this has been mentioned before, but I was not able to find it if it was.
Basically, I have several strings which may or may not contain a <span> tag enclosing text. (i.e. <span>some Text</span>). What I'd like to do, is find that text, if it exists (if it doesn't then exit the function), and add another span onto the end of it.
basically turn this: <span>some text</span>
into this: <span>some text</span><span class="addedText">some text</span>.
I'm really new to php and have gone through many tutorial sites. My thought is to use strpos to find where span begins and where it ends, then replace it with extra span and return the new string. (I hope it's not too confusing)
I'm wanting to use it for WordPress (if you're familiar) to construct dynamic pullquotes for text I specify without having to write the text twice.
Thank you in advance.
Basically, I have several strings which may or may not contain a <span> tag enclosing text. (i.e. <span>some Text</span>). What I'd like to do, is find that text, if it exists (if it doesn't then exit the function), and add another span onto the end of it.
basically turn this: <span>some text</span>
into this: <span>some text</span><span class="addedText">some text</span>.
I'm really new to php and have gone through many tutorial sites. My thought is to use strpos to find where span begins and where it ends, then replace it with extra span and return the new string. (I hope it's not too confusing)
I'm wanting to use it for WordPress (if you're familiar) to construct dynamic pullquotes for text I specify without having to write the text twice.
Thank you in advance.