public function similarity($text1, $text2) 
    {
        if($this->useCache && !isset($this->cache[$text2])) {
            $this->cache[$text2] = Text::getAllSubStrings($text2);
        }
        
        $intersection = array_intersect( Text::getAllSubStrings($text1), ($this->useCache) ? $this->cache[$text2] : Text::getAllSubStrings($text2));
        $max = 0;
        $lcs = '';
        foreach($intersection as $substr)
        {
            $strlen = mb_strlen($substr);
            if( $strlen > $max) {
                $max = $strlen;
                $lcs = $substr;
            }
        }
        return $lcs;
    }
public function similarity($text1, $text2) 
    {
        if($this->useCache && !isset($this->cache[$text2])) {
            $this->cache[$text2] = Text::getAllSubStrings($text2);
        }
        
        $intersection = array_intersect( Text::getAllSubStrings($text1), ($this->useCache) ? $this->cache[$text2] : Text::getAllSubStrings($text2));
        $max = 0;
        $lcs = '';
        foreach($intersection as $substr)
        {
            $strlen = mb_strlen($substr);
            if( $strlen > $max) {
                $max = $strlen;
                $lcs = $substr;
            }
        }
        return $lcs;
    }
public function similarity ( $ text1 , $ text2 ) { if ( $ this -> useCache && ! isset ( $ this -> cache [ $ text2 ] ) ) { $ this -> cache [ $ text2 ] = Text :: getAllSubStrings ( $ text2 ) ; } $ intersection = array_intersect ( Text :: getAllSubStrings ( $ text1 ) , ( $ this -> useCache ) ? $ this -> cache [ $ text2 ] : Text :: getAllSubStrings ( $ text2 ) ) ; $ max = 0 ; $ lcs = '' ; foreach ( $ intersection as $ substr ) { $ strlen = mb_strlen ( $ substr ) ; if ( $ strlen > $ max ) { $ max = $ strlen ; $ lcs = $ substr ; } } return $ lcs ; }
Returns the Longest common substring
@param string $text1
@param string $text2
@return string
Returns the Longest common substring