{"id":1130,"date":"2012-08-06T20:09:09","date_gmt":"2012-08-06T20:09:09","guid":{"rendered":"http:\/\/www.phpmind.com\/blog\/?p=1130"},"modified":"2012-08-06T20:12:22","modified_gmt":"2012-08-06T20:12:22","slug":"how-to-filter-bad-words","status":"publish","type":"post","link":"https:\/\/www.phpmind.com\/blog\/2012\/08\/how-to-filter-bad-words\/","title":{"rendered":"How to filter bad words?"},"content":{"rendered":"<p>You can use this simple function to filter bad words. <\/p>\n<p>Please see attachment for mysql table of frequently used 458 bad words. http:\/\/www.phpmind.com\/codedemo\/php-bad-word-filter\/bad_word.txt.zip<br \/>\nYou can add more word easily as you know more!!<\/p>\n<pre lang=\"php\">\r\n\r\n  function bad_wordcensor($txt)\r\n  {\r\n    $q = mysql_query(\"SELECT bad_word, replacement FROM bad_words\");\r\n    while ($row_bad = mysql_fetch_array($q))\r\n    {\r\n      $txt = str_ireplace($row_bad['bad_word'], $row_bad['replacement'], $txt);\r\n    }\r\n\r\n  return $txt;\r\n  }\r\n\r\necho bad_wordcensor($_POST[\"comments\"]);\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>You can use this simple function to filter bad words. Please see attachment for mysql table of frequently used 458 bad words. http:\/\/www.phpmind.com\/codedemo\/php-bad-word-filter\/bad_word.txt.zip You can add more word easily as you know more!! function bad_wordcensor($txt) { $q = mysql_query(&#8220;SELECT bad_word, replacement FROM bad_words&#8221;); while ($row_bad = mysql_fetch_array($q)) { $txt = str_ireplace($row_bad[&#8216;bad_word&#8217;], $row_bad[&#8216;replacement&#8217;], $txt); } return [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_exactmetrics_skip_tracking":false,"_exactmetrics_sitenote_active":false,"_exactmetrics_sitenote_note":"","_exactmetrics_sitenote_category":0,"footnotes":""},"categories":[3],"tags":[],"class_list":["post-1130","post","type-post","status-publish","format-standard","hentry","category-php"],"_links":{"self":[{"href":"https:\/\/www.phpmind.com\/blog\/wp-json\/wp\/v2\/posts\/1130","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.phpmind.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.phpmind.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.phpmind.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.phpmind.com\/blog\/wp-json\/wp\/v2\/comments?post=1130"}],"version-history":[{"count":5,"href":"https:\/\/www.phpmind.com\/blog\/wp-json\/wp\/v2\/posts\/1130\/revisions"}],"predecessor-version":[{"id":1134,"href":"https:\/\/www.phpmind.com\/blog\/wp-json\/wp\/v2\/posts\/1130\/revisions\/1134"}],"wp:attachment":[{"href":"https:\/\/www.phpmind.com\/blog\/wp-json\/wp\/v2\/media?parent=1130"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.phpmind.com\/blog\/wp-json\/wp\/v2\/categories?post=1130"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.phpmind.com\/blog\/wp-json\/wp\/v2\/tags?post=1130"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}