I have the following code and using css text-transform property with a value of capitalize or php ucwords()
I get the title capitalized but when the title is provided with all letters as capitals it doesn’t work. How can I achieve the output to be capitalized regardless of the title provided?
<h4 style="text-transform: capitalize;"> <a href="{{ route('posts.show', $post )}}">{{ $post->title }}</a> </h4>
Advertisement
Answer
A php solution would be to convert case to lower and then use ucfirst
$text = 'THIS IS A TITLE'; $normalText = ucfirst(strtolower($text)); echo $normalText;