Reputation: 1965
I'm trying to convert a variable that say has, "hello-big-boy" or "hello-big" or even just say, "hello" into a variable that would have all the dashes converted to spaces, and the first letter of each word as a capital. So "hello-big-boy" would become Hello Big Boy, and "hello-big" would become Hello Big, and "hello" would become Hello.
Any help is much appreciated guys! Thanks :)
Upvotes: 1
Views: 46
Reputation: 68486
Since there is only a minor replace , you could avoid making use of regex
and go with the native PHP functions.
<?php
$str='hello-big-boy';
echo ucwords(str_replace('-',' ',$str)); //"prints" Hello Big Boy
Upvotes: 1