I have this simple string:
echo ucwords("<row><cell><chars class='subHeader'><value>how much time do you spend</value></chars></cell></row>");
But its outputting like so:
<row>
<cell>
<chars Class="subHeader">
<value>how Much Time Do You Spend</value>
</chars>
</cell>
</row>
As long as your HTML is that simple like in the input, specifically being US-ASCII encoded and not containing any CDATA sections, this might work:
This does work because
>is a reserved character in HTML. Adding a space after each will makeucwordsto work as documented. Afterucwordshas done it’s job, the change is reverted.However this might bring you into problems if
>sequences existed earlier which will be removed as well. So take care.