以下の仕様を満たすプログラムがうまく機能しません。
どこがまちがっているのか教えてください。
PHP
1<?php 2/*引数wordに対して次の処理を行い戻り値としたいとき 3・末尾が s, sh, ch, o, x のいずれかである英単語の末尾に es を付ける 4・末尾が f, fe のいずれかである英単語の末尾の f, fe を除き、末尾に ves を付ける 5・末尾の1文字が y で、末尾から2文字目が a, i, u, e, o のいずれでもない英単語の末尾の y を除き、末尾に ies を付ける 6・上のいずれの条件にも当てはまらない英単語の末尾には s を付ける 7*/ 8function checks($word){ 9 if (mb_substr($word, -1) == array("s","o","x")) { 10 $word .= "es"; 11 }elseif (mb_substr($word, -2) == array("sh","ch")) { 12 $word .= "es"; 13 }elseif (mb_substr($word, -1) == "f") { 14 $word = rtrim($word,"f"); 15 $word .= "ves"; 16 }elseif (mb_substr($word, -2) == "fe") { 17 $word = rtrim($word,"fe"); 18 $word .= "ves"; 19 }elseif(mb_substr($word, -2) != array("ay","iy","uy","ey","oy")) { 20 $word = rtrim($word,"y"); 21 $word .= "ies"; 22 }else{ 23 $word .= "s"; 24 } 25 return $word; 26} 27?>
回答1件
あなたの回答
tips
プレビュー