Nice easy way of capitalizing names such as "o'sullivan"?
<p>Take two strings:</p>

<pre><code>"o'sulLivAn"
"doUble-baRrel"
</code></pre>

<p>Desired result:</p>

<pre><code>"O'Sullivan"
"Double-Barrel"
</code></pre>

<p>I thought <code>ucwords(strtolower($str))</code> might do the trick but it treats the strings as a single word.</p>

<p>I know I can <code>explode</code>, or rather <code>preg_split</code> the string and then capitalize the parts and put it back together again, but I'm wondering if there's a better way of doing it?</p>

<p>Usually with PHP and this sort of thing there tends to be a function hiding away somewhere that'd be useful but isn't obvious or well known.</p>
