ユーザーが入力した文字が小文字または大文字であることを確認したい。小文字の場合は大文字に変更したい。大文字の場合は小文字に変更したい。
<?php
$string=$_POST['string'];
$arr=str_split($string);
$arrlen=strlen($string);
$arrcaps=array("A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"," ");
$arrsmall=array("a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"," ");
//print_r($arrsmall);
for($i=0;$i<$arrlen;$i++)
{
for($j=0;$j<27;$j++)
{
if($arr[$i]==$arrcaps[$j])
{
echo $arrsmall[$j];
}
}
for($k=0;$k<27;$k++)
{
if($arr[$i]==$arrsmall[$j])
{
echo $arrcaps[$j];
}
}
}
?>
上記のプログラムを実行します。大文字を小文字に変更します。ただし、小文字を大文字に変更しません。
間違えたところ。この問題を解決します。
前もって感謝します...