preg_replace matching word with inner tag
Say you have a string:
I want to wrap certain words with a span tag, like:
$str='This is a<wbr /> line of te<wbr />xt';
But obviously that doesnt work because in the string there is a '<wbr />' in the middle of it. Note that I can't strip out the '<wbr />'.
Does anyone know how I would go about doing this?
By the way, it's worth pointing out that there won't necessarily be a '<wbr />' in the middle of the word and the location of it is arbitrary.. e.g.
Also there could be more than one, such as:
$str='This is a<wbr /> line of te<wbr />xt, look at this text and how good this tex<wbr />t is.';
$str='t<wbr />e<wbr />xt';
Last edited by artemis; 08-23-2007 at 08:20 AM.
Nevermind, after a phat amount of regexing i figured it out
hi i would be very interested in your olution if you still remember it.
I have this as an input:
<p>How are you <span style='text-decoration:underline'>doing?</span></p>
i need to have the following output:
<p><span id='w_1'>Hello</span> <span id='w_2'>wo<em>rld</em></span></p>
<p><span id='w_3'>How</span> <span id='w_4'>are</span> <span id='w_5'>you</span> <span id='w_6'><span style='text-decoration:underline'>doing?</span></span></p>
thanks in advance !
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)