I have strings that need converting like so,
'hello world' = 'helloWorld'
And also the same in reverse,
'helloWorld' = 'hello world'
So far all I have for both the conversions is this for the first,
$str = 'hello world';
$str = lcfirst(str_replace(' ', '', ucwords($str))); // helloWorld
And the second,
$str = 'helloWorld';
$str = preg_split('/(?=[A-Z])/', $str);
$str = strtolower(implode(' ', $str)); // hello world
Can this not be achieved any easier or any more efficient?