Warning: file_get_contents(/home/gcms/public_html/skin/datas/users/goro/skin/2017/amp.css): failed to open stream: No such file or directory in /home/gcms/public_html/Gcms/Amp.php on line 32
ฟังก์ชั่นตัดคำหยาบ PHP

GORAGOD

ฟังก์ชั่นตัดคำหยาบ PHP

ฟังก์ชั่นตัดคำหยาบซึ่งสามารถเพิ่มคำที่ต้องการตัดได้ โดยนำไปใส่ใน array $wordrude

function CheckRude( $temp )
{
     $wordrude = array( "ashole","xxx","xxx","bitch","xxx","xxx","shit","xxx","xxx","fuck","dick","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>"; //ข้อความที่ต้องการให้เปลี่ยนเป็น

     for ( $i = 0 ; $i < sizeof( $wordrude ) ; $i++ )
     {
          $temp = eregi_replace ( $wordrude[$i] , $wordchange , $temp );
     };
    
     return $temp;
 }

การใช้งาน

<?
  $txt = 'กูจะฆ่าxxx';
  echo CheckRude( $txt ); // xxxจะฆ่าxxx
?>