私はphpを使用して、あるテキストエリアからテキストを交換し、別のテキストエリアに表示していますが、ほとんどは機能しますが、残念ながら一部の部分は機能しません。
私はstr_ireplace
これまでに 60 の異なる単語を使用しており、さらに多くの単語を使用しています。私の問題のいくつかの例は次のとおりです。
old - auld
old man - gadgie
上を見ると、最初の単語はスワップされていない単語で、2 番目の単語は新しい単語です。ただし、テキストに老人を入れると、「ガジェット」ではなく「オールドマン」になります。
これは、"old man - gadgie" の前に "old-auld" と宣言したことが原因である可能性があることを知っています。
しかし、別の問題は次のとおりです。
yes - aye
no - nar
繰り返しますが、最初の単語はオリジナルで、2 番目はスワップ後です。「yesterday」と書くと「ayeterday」と表示され、「nose」と書くと「narse」と表示されます。
それが別の単語の一部である場合ではなく、それ自体で「はい」のみを変更する方法はありますか?
そして、「老人」と「老人」を別々の代わりにする方法はありますか?
それが理にかなっていることを願っています
私のコードstr_ireplace
:
<form method="POST" action="post.php" >
<textarea name="status2" cols="50" rows="5"/>
<?php echo str_ireplace(array ('old','awkward','all','again','behind','along','alright','hello','among','children','yes','child','kids','food','barnard castle','beer','book','blow','beautiful','bird','burst','brown','burn','boots','came','nice','cold','church','clothes','stick','dirty','clever','cloth','cow','crow','stool','crown','pigeon','dad','darlington','dead','do','devil','dont','do not','durham','down','drown','punch','ditch','eye','fall','trouble','condition','four','stupid','old man','go','going','jumper','give over','grandad','hold','get away','home'),
array ('auld', 'aakwad', 'aall','agyen','ahint','alang','alreet','alreet','amang','bairns','aye','bairn','bairns','bait','barney','beor','beuk','blaa','bonny','bord','borst','broon','bourn','byeuts','cam','canny','card','chorch','claes','clag','clarty','clivvor','cloot','coo','craa','cracket','croon','cushat','da','darlo','deed','dee','deil','divvent','divvent','dorham','doon','droon','dunsh','dyke','Eee','faa','fash','fettle','fower','gaumless','gadgie','gan','gannin','ganzie','giveower','granda','haad','hadaway','hyem'),$status); ?>
</textarea><br>
私が言ったように、60以上の単語があります。
関連性がないかもしれないと思ったので、最初はコードを追加しませんでした。