PHP calculates title title similarity Ratio method, PHP calculates title title _php Tutorial

Source: Internet
Author: User

PHP calculates the title similarity ratio method, PHP calculates title title


In this paper, we describe the method of calculating the similarity ratio of title titles in PHP. Share to everyone for your reference. Specific as follows:

<?php/* * * @param string $title _1 Topic 1 * @param string $title _2 topic 2 * @return float $percent similar percentage */function title_si Milar ($title _1, $title _2) {  $title _1 = get_real_title ($title _1);  $title _2 = get_real_title ($title _2);  Similar_text ($title _1, $title _2, $percent);  return $percent;} /** * PHP collects the article title and goes to copyright * @param string $html The HTML source code to be collected * @return string */function get_real_title ($str) {  $str = str_re Place (Array ('-', '-', ' | '), ' _ ', $str);  $splits = Explode (' _ ', $str);  $l = 0;  foreach ($splits as $TP) {    $len = strlen ($TP);    if ($l < $len) {$l = $len; $tt = $TP;}  }  $tt = Trim (Htmlspecialchars ($TT));  return $TT;} The following is the test $title_1 = ' Code phpcms V9 product officially released public beta version '; $title _2 = ' phpcms re-war Lake V9 product officially released beta '; $percent = Title_similar ($title _1,$ title_2); Echo ' similarity percent: '. $percent. ' % '; Echo '
\ n ";? >

I hope this article is helpful to everyone's PHP programming.

http://www.bkjia.com/PHPjc/1039206.html www.bkjia.com true http://www.bkjia.com/PHPjc/1039206.html techarticle php calculate Title Title similarity Ratio method, PHP calculate title title in this paper, we describe the method of calculating the similarity ratio of title titles in PHP. Share to everyone for your reference. as follows: PHP/* ...

  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.