Jump to content

ECHO STOP WORDS BEFORE ENTER TO DB


williamh69

Recommended Posts

Hi guys, thank so much for all your help. I have this question: I have a two tables one is a content text, and the other one there are the stop words. I would like to match my content with those stop words and echo them, before submit to db.

  content                    stopwords

content_id                    words

content

 

any suggestion thank you

Link to comment
https://forums.phpfreaks.com/topic/288255-echo-stop-words-before-enter-to-db/
Share on other sites

i found this class to use it

<?php 
class Cleaner {

    var $stopwords = array(" find ", " about ", " me ", " ever ", " each ", " update ", " delete ", " add ", " insert ",
 " where ", " i ", " a ", " my ");//you need to extend this big time.

    var $symbols = array('/','\\','\'','"',',','.','<','>','?',';',':','[',']','{','}','|','=','+',
'-','_',')','(','*','&','^','%','$','#','@','!','~','`');

    function parseString($string) {
        $string = ' '.$string.' ';
        $string = $this->removeStopwords($string);
        $string = $this->removeSymbols($string);
        return $string;
    }

    function removeStopwords($string) {
        for ($i = 0; $i < sizeof($this->stopwords); $i++) {
            $string = str_replace($this->stopwords[$i],' ',$string);
        }

        return trim($string);
    }

    function removeSymbols($string) {
        for ($i = 0; $i < sizeof($this->symbols); $i++) {
            $string = str_replace($this->symbols[$i],' ',$string);
        }

        return trim($string);
    }
}

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.