文字列置き換え(str_replace)
<html>
<head>
<title>文字列置き換え</title>
</head>
<body>
<center>
<h1 style="font-size:15px;text-align:center">文字列置き換え</h1>
<form action="" method="POST">
<textarea cols="60" rows="10" name="text">
<?php
//文字列置き換え(str_replace を str_ireplace に変更で半角英の大文字小文字区別なしになる)
$text = str_replace($_POST['word1'], $_POST['word2'], $_POST['text']);
echo $text;
?>
</textarea><br>
<input type="text" size="30" name="word1" value="">
⇒
<input type="text" size="30" name="word2" value="">
<input type="submit" value="置き換え"><br>
</form>
<br>
<a href="/">トップページへ</a>
</center>
</body>
</html>
〔 実行する 〕