hi , i want a function , Please help me,,,,,,,, when user post reply $reply="Hello this is testing message"; //user reply text $res=mysql_query("select * from wordfilter"); while ($row=mysql_fetch_array($res)){ $word=$row['words']; // delete, insert, drop , etc.......... } PHP: if $reply any word match to $word then he replace it first word and last word same and middle word replace to ***** forexemple he found sexy and hi also in my database (in $word) then he replace it s**y if hi found one word then replace one if found two word then two .....there ....... four ................................................................................
function Replace( $Word ) { $Replace = substr( $Word, 0, 1 ); for( $x = 0; $x <= strlen( $Word ) - 2; $x++ ) $Replace .= "*"; $Replace .= substr( $Word, -1 ); return $Replace; } $reply = "Hello this is a sexy testing vagina message"; $res = mysql_query("select * from wordfilter"); while( $row = mysql_fetch_array( $res ) ) { $Word = $row['words']; if( stripos( $reply, $Word ) ) $reply = str_ireplace( $Word, Replace( $Word ), $reply ); } PHP: Should work for you. Then again, it's 2am and untested.