gOOGLE cASE of a given sentence | PHP program to convert a sentence to gOOGLE cASE . ; empty strings ; convert input to upper case ; checki if character is not a space and adding it to $w ; converting first character to lower case and subsequent initial letter of another word to lower case ; Driver code
< ? php function convert ( $ str ) { $ w = " " ; $ z = " " ; $ str = strtoupper ( $ str ) . " ▁ " ; for ( $ i = 0 ; $ i < strlen ( $ str ) ; $ i ++ ) { $ ch = $ str [ $ i ] ; if ( $ ch != ' ▁ ' ) $ w = $ w . $ ch ; else { $ z = $ z . strtolower ( $ w [ 0 ] ) . substr ( $ w , 1 ) . " ▁ " ; $ w = " " ; } } return $ z ; } $ str = " I ▁ got ▁ intern ▁ at ▁ geeksforgeeks " ; echo ( convert ( $ str ) ) ; ? >