သင့်အနေဖြင့် အောက်ပါ ဥပမာမှ form ၊ textarea ၊ isset ၊ strtolower နှင့် str_replace တို့၏ အသုံးပြုပုံကို လေ့လာနိုင်ပါသည်။ Text box တွင် သင်ရိုက်သမျှ love ဆိုသည့် စာလုံးသည် hate ဆိုသည့် စာလုံး အဖြစ်သို့ ပြောင်းလဲသွားလိမ့်မည်။
<?php
$find = 'love';
$replace = 'hate';
if(isset($_POST['user_input']) && !empty($_POST['user_input'])){
$user_input = strtolower($_POST['user_input']);
$user_input_new = str_replace($find, $replace, $user_input);
echo $user_input_new.'</br>';
}else{
echo 'Please fill in the text box!';
}
?>
<form action = "wordcensoring.php" method = "POST">
<textarea name = "user_input" cols = "40" widths = "500"></textarea></br></br>
<input type = "submit" value = "Submit">
</form>
What do you think?
Send us feedback!