I need wrap long words, each one in span tags, example:
$string = 'aaaaaaaaaaaaaaaa{}^?¿*!-<a href="#">link here</a>aaaaaaaaaa<br />aaaa';
I need print this:
( cut each 8 characters ignoring html tags )
"<span>aaaaaaaa</span>
<span>aaaaaaaa</span>
<span>{}^?¿*!-</span>
<a href="#">link here</a>
<span>aaaaaaaa</span>
aa
<br />
aaaa"
something like what makes facebook (<span class="word_break"></span>)
facebook code:
<span>aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa</span><wbr></wbr><span class="word_break"></span>
any idea? :)
thanks so much
I wrong a PHP functio for it
word_wrap
which produces the output of
Ok I was a little off. You need str_split(); this should give you a workable array.
Look at the docs here
Just loop through that adding a span to each loop.
EDIT
I just realized that this won't solve the problem of "ignoring the HTML tags". You could probably tweak it real quick. Just don't go down the DARK ROAD of parsing HTML with REGEX please. Aloha.