ฟังก์ชั่นตัดคำหยาบ PHP
ฟังก์ชั่นตัดคำหยาบซึ่งสามารถเพิ่มคำที่ต้องการตัดได้ โดยนำไปใส่ใน array $wordrude for ( $i = 0 ; $i < sizeof( $wordrude ) ; $i++ )
{
$wordrude = array( "xxx","xxx","xxx","xxx","xxx","xxx","xxx","xxx","xxx","xxx","xxx","xxx","xxx","xxx","xxx","มึง","xxx","xxx","xxx","xxx","xxx","xxx","xxx","xxx","กู","ควย","xxx","xxx","xxx","xxx","ปี้","เหี้ย","xxx","xxx","xxx","xxx","xxx","xxx","xxx","xxx","xxx","สัด","เย็ด","หี","xxx","แม่ง","xxx","xxx","แตด" ) ; //คำหยาบ
$wordchange = "<font class=\"red\">xxx</font>"; //ข้อความที่ต้องการให้เปลี่ยนเป็น
{
$temp = eregi_replace ( $wordrude[$i] , $wordchange , $temp );
};
return $temp;
}
การใช้งาน
<?
$txt = 'กูจะฆ่ามึง';
echo CheckRude( $txt ); // xxxจะฆ่าxxx
?>