How to set lower text and first character as CAPS?
I have code like:
PHP Code:
foreach( $var as $i => $element ) {
$var [ $i ] = ucfirst ( $element );
}
Issue is that exploded text is all the time CAPS like
TEXT
When I try to ucfirst it will be not Text as all are CAPS.
PHP:
Returns a string with the first character of str capitalized, if that character is alphabetic.
If I try $var[$i] = mb_strtolower($element); it will be all lower.
How to set in one line mb_strtolower and the first character capitalized like Text?
PHP Code:
$text = ucfirst ( strtolower ( $text ));
However, you might not like this if $text contains proper names which should be capitalized, or more than one sentence, or acronyms, or anything else that would require a capitalized letter in the middle of the string.
"Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
~ Terry Pratchett in
Nation
eBookworm.us
Originally Posted by
NogDog
PHP Code:
$text = ucfirst ( strtolower ( $text ));
I have tested many possibilities.
It works $var[$i] = mb_convert_case(mb_strtolower($element), MB_CASE_TITLE);
But still is issue UTF-8 encoding. How to work some special characters like č.
It shows me �
I worked some other function mb_strtolower($variable, 'UTF-8'))
How to set UTF-8 inside:
$var[$i] = mb_convert_case(mb_strtolower($element), MB_CASE_TITLE);
Thread Information
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)
Posting Permissions
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
Forum Rules
Bookmarks