public function similarity($text1, $text2) 
    {
        if(is_string($text1) && is_string($text2)) {
            $text1 = str_split($text1);
            $text2 = str_split($text2);
        }         
        $inter = array_intersect( $text1, $text2 );
        $union = array_unique( ($text1 + $text2) );
        return count($inter) / count($union);                
    }
public function similarity($text1, $text2) 
    {
        if(is_string($text1) && is_string($text2)) {
            $text1 = str_split($text1);
            $text2 = str_split($text2);
        }         
        $inter = array_intersect( $text1, $text2 );
        $union = array_unique( ($text1 + $text2) );
        return count($inter) / count($union);                
    }
public function similarity ( $ text1 , $ text2 ) { if ( is_string ( $ text1 ) && is_string ( $ text2 ) ) { $ text1 = str_split ( $ text1 ) ; $ text2 = str_split ( $ text2 ) ; } $ inter = array_intersect ( $ text1 , $ text2 ) ; $ union = array_unique ( ( $ text1 + $ text2 ) ) ; return count ( $ inter ) / count ( $ union ) ; }
Returns the Jaccard Index
@param string|array $text1
@param string|array $text2
@return float
Returns the Jaccard Index