Reverses a word in an English sentence, and the corresponding position is case-insensitive.
Enter an English sentence, only English text (a-z, A-Z), each word between only one space lattice, front and back no space.
The returned result is to reverse the alphabetic order of each word, but the order of words and the uppercase and lowercase positions of letters remain unchanged.
Example:
Enter This is an Apple on eBay
Output: Siht si na Elppa no yAbe
/*** Reverse the word in an English sentence, and keep the corresponding location case unchanged * @ param [type] $ str [description] * @ return [type] [description] */function stringReverse ($ str) {// convert each word to lowercase and reverse it $ tmp = strtolower ($ str); $ tmp = implode ("", array_map ("strrev", explode ("", $ tmp); $ strlen = strlen ($ tmp); // traverses the original string and converts the corresponding position character of the new string to uppercase while ($ strlen> 0) {$ strlen --; $ ord = ord ($ str {$ strlen}); if ($ ord> 64 & $ ord <90) {$ tmp {$ strlen} = strtoupper ($ tmp {$ strlen}) ;}return $ tmp ;}