php - How do I convert parts of the string to uppercase? -
I have a string that I want to convert to uppercase besides the word 'and' which would always be surrounded by underscores is. / P>
then it becomes me_and_you ME_and_YOU does not always contain 'and' in the string, so it can be you me_you ME_YOU
Obviously strtoupper () makes the whole thing uppercase Do I have to use something like preg_split () or explosion ()?
You could probably write a regex to do this, but there would be an easy solution solution:
echo str_replace ('_ AND_', '_and_', strtoupper ($ your_string));
Comments
Post a Comment