The code above replaces the first letter of $myVar which is small letter “a” to the big letter “A”.
The result is what I wanted when I knew the first letter is “a”.
But How can I change it when I don’t know it?
If it is “a”, I like to change it “A”.
If it is “b”, I like to change it “B”.
If it is “c”, I like to change it “C”.
If it is “d”, I like to change it “D”.
: :
How can I replace the first letter of $myVar to the big letter?
I googled ‘php replace the 1st letter which is lower case to upper case’, and guess what appeared in position #4? The php manual with the function Mikl mentioned…
I am not positive, but I think the OP wants to respect the existing UC letters
That’s what I assumed. And, as Guido says, that’s what ucfirst() does.
If the function made the first letter upper case and the remaining letters lower-case, I’d expect it be called proper(). As far as I know, PHP doesn’t have one of those.
Well I accept your thanks most graciously, but I have to say others have provided the answer.
I merely proved (again) to myself and others, that it is by trying to be a good member and stick your neck out and help others you expose yourself to correction.
When that happens I learn from it.
It can be humbling, but really, if there are any other passive readers and not participators out there, stick your neck out and jump in and provide your answers when you see the opportunity.
You will get things wrong and it might make you feel a bit daft for not knowing something but you will learn a lot, you’ll be helping others and you will make more friends.