I am using the following code to capitalize each word in a sentence, but I am unable to capitalize words with brackets attached.
PHP Code:
<?php
$str = "[this is the {command line (interface ";
$output = ucwords(strtolower($str));
echo $output;
Output:
[this Is The {command Line (interface
But my expected output should be:
[This Is The {Command Line (Interface
How can I handle words with brackets? There may be multiple brackets.
For example:
[{this is the ({command line ({(interface
I want to find a general solution/function in PHP.