Sunday, April 03 2016

Predict illegal words from the content in codeigniter

To avoid the illegal words in your content as you are using codeigniter provide word_censor functions.Here we are brief explain about this function. First you mention what are the words are you going to skip from the content. Those values are maintain your table.


CREATE TABLE `test`.`get_illegal_words` (`word_id` INT(11) NOT NULL AUTO_INCREMENT PRIMARY KEY, `illegal_word` VARCHAR(255) NOT NULL) ENGINE = InnoDB;

In Codeigniter:

Load helper file for text.
$this->load->helper ('text');                          
Get the illegal words from the table .
$query = $this->settingsmodel->get_illegalwords(1);
	foreach($query as $row)
		$id = $row->id;
		$illwords = $row->illwords;
Compare the user input and table
$string = word_censor($pagecontent, $words, 'Beep!');     
$pos = strrpos($string, "Beep!");
if (strstr($string, 'Beep!') !== false)
	$this->session->set_flashdata('error',"Dont write illegal words to this post");
	/* Insert Your Code */

Share Your Thoughts


I’m Blogger and Programming Blog, Tutorials, PHP, MySQL, jQuery, Laravel, Wordpress and Codeigniter