The code above replaces the first letter of $myVar which is small letter "a" to the big letter "A".Code:code $myVar="abCd"; $myVar1 = str_replace('a','A', $myVar) echo $myVar1; result AbCd
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?



Reply With Quote







Bookmarks