How to covert string to uppercase except the string in () in php
For example: abc(abc)(ABC)(abc)abc
>>>change to>>> ABC(abc)(ABC)(abc)ABC
....
$str = 'abc(abc)(ABC)(abc)abc abc(abc)';
function toupper($str) {
???
}
....
How to covert string to uppercase except the string in () in php
For example: abc(abc)(ABC)(abc)abc
>>>change to>>> ABC(abc)(ABC)(abc)ABC
....
$str = 'abc(abc)(ABC)(abc)abc abc(abc)';
function toupper($str) {
???
}
....
Provided the string pattern remains consistent,
function toUpper($str)
{
$exp = explode('(', $str);
$to_up = strtoupper($exp[0]);
$inside_brackets = '('.$exp[1];
return $to_up.$inside_brackets;
}
echo toUpper("abc(def)");