Php calculates the title similarity ratio, and php calculates the title _ PHP Tutorial.

Source: Internet
Author: User
Php calculates the title similarity ratio, and php calculates the title. Php calculates the title similarity ratio. This document describes how to calculate the title similarity ratio of php. Share it with you for your reference. The details are as follows: php * php calculates the title similarity ratio, and php calculates the title

This example describes how to calculate the title similarity ratio in php. Share it with you for your reference. The details are as follows:

<? Php/*** @ param string $ title_1 Question 1 * @ param string $ title_2 Question 2 * @ return float $ percent similar percentage */function title_similar ($ 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 ;} /*** collect the article title in php and copyright it * @ param string $ html the html source code to be collected * @ return string */function get_real_title ($ str) {$ str = str_replace (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 ;} // test $ title_1 = 'code: PHPCMS V9 product officially released public beta version'; $ title_2 = 'phpcms then vs. Jianghu V9 product officially released public beta version '; $ percent = title_similar ($ title_1, $ title_2); echo 'similar percentage :'. $ percent. '%'; echo"
\ N ";?>

I hope this article will help you with php programming.

Example: This article describes how to calculate the title similarity ratio of php. Share it with you for your reference. Details: php /*...

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.