We are a php shop and prefer you answering in php,

But you might answer in any other languages in case you are not familiarwith it, we can read C#, Java, C++, Perl, Ruby, etc.


The input would be an English sentence as a string, please transforms it as described below and return a new...

The sentence would contains only alphabet(a-z and A-Z) and space, each word would be separated by exactly...

space. There would be no spaces before and after the sentence.

Please return the string with each word spelled in reverse, however, the position of the capitalization of each ...

should stay the same for each word.

For example:

Input: This is an Apple on eBay

Output: sihT si na elppA no yaBe

function rev($arr) {
    $arr = explode(" ",$arr);
    foreach($arr as &$v){
        $v = strrev($v);
    return implode(" ",$arr);
$arr = "This is an Apple on eBay";
$res = rev($arr);

输出为:sihT si na elppA no yaBe




您的电子邮箱地址不会被公开。 必填项已用*标注