How to convert this:
"Elephant, Africa, landscape"
into this:
"elephant, Africa, landscape"
I tried using strlower and lcfirst php functions, but that is not what I wish. I wish just fist character of just first word to be lowercase, not all sentence lowercase or all words to be with first character lowercase.
Is there something to get first character of first word only lowercase?
UPDATE:
I wish to show post title as keywords, and I use this:
$title = get_the_title( $post->post_parent ); // Get post title
$parts = explode( ' ', $title ); // Delimetar for words in post title " "
$str = '';
foreach ($parts as $word) {
$str.= lcfirst(post_title_as_keywords($word)); // Lowercase first character
}
$str = substr($str, 0,-2);
echo $str;
And this is what I get:
"elephant, africa, landscape"
How to prevent lowercase effect on all words?
You're using lcfirst()
once per word (inside the for
loop). Try applying lcfirst()
to str after the loop, instead of inside it:
$str = lcfirst(substr($str, 0,-2));