Page 1 of 1

how to lowercase the first letter in a string

Posted: Mon Jan 17, 2005 4:52 am
by jasongr
Hello

Assume I have a string like so:
$test = 'Hello My Name is John";

I would like to lowercase the first letter in the string so the stringw will become

"hello My Name is John"

I saw function ucfirst(), but there is no lcfirst()

you can assume that the first letter is latin

regards

Posted: Mon Jan 17, 2005 5:36 am
by JAM
You could make use of strtolower(substr($test, 1, 1)) or somethnig similiar, combined with other string functions.

Fins first letter, strtolower it and put it back in.

Posted: Mon Jan 17, 2005 5:42 am
by jasongr
Here is a simple solution I found:

Code: Select all

$string{0} = strtolower($string{0});

Posted: Mon Jan 17, 2005 6:04 am
by JAM
jasongr wrote:Here is a simple solution I found:

Code: Select all

$string{0} = strtolower($string{0});
That would be easier, yes. :wink: