search
HomeBackend DevelopmentPHP Tutorial Php 比较字符串相像度

Php 比较字符串相似度

除了利用cookies、IP限制等技术外,我们可以利用PHP自身带的similar_text函数来判断用户发帖内容的相似度。

?

????similar_text()?函数计算两个字符串的匹配字符的数目,也可以计算两个字符串的相似度(以百分比计)。???

?

语法

similar_text(string1,string2,percent)
参数 描述
string1 必需。规定要比较的第一个字符串。
string2 必需。规定要比较的第二个字符串。
percent 可选。规定供存储百分比相似度的变量名。

?

?

实例:

?

<?php
similar_text("Web Design & Development","Low Cost, Custom Web Design",$percent);
echo "Percent: $percent%"; ;
?>
?

?

结合实际:

?

<?php
$query = mysql_query("select * from $table") or die("Query failed");

while ($row = mysql_fetch_array($query)) {
      similar_text(strtoupper($_POST['name']), strtoupper($row['reserved']), $similarity_pst);
      if (number_format($similarity_pst, 0) > 90){
        $too_similar = $row['reserved'];
        print "The name you entered is too similar the reserved name "".$row['reserved'].""";
        break;
       }
    }
?>
?

?

转帖注明出处:http://justcoding.iteye.com/blog/988504

?

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
如何通过拖放在Power Query中对多列进行重新排序如何通过拖放在Power Query中对多列进行重新排序Mar 14, 2024 am 10:55 AM

在这篇文章中,我们将向你展示如何通过拖放在PowerQuery中对多列进行重新排序。通常,从各种来源导入数据时,列可能不是所需的顺序。重新排序列不仅允许您按照符合您的分析或报告需求的逻辑顺序排列它们,还可以提高数据的可读性,并加快过滤、排序和执行计算等任务。如何在Excel中重新排列多个列?在Excel中,重新排列列的方法有多种。您可以简单地选择列标题,然后将其拖动到所需位置。但是,当处理包含许多列的大表时,这种方法可能会变得繁琐。为了更高效地重新排列列,您可以使用增强查询编辑器。通过增强查询编

React Query 数据库插件:实现数据导入和导出的方法React Query 数据库插件:实现数据导入和导出的方法Sep 26, 2023 pm 05:37 PM

ReactQuery数据库插件:实现数据导入和导出的方法,需要具体代码示例随着ReactQuery在前端开发中的广泛应用,越来越多的开发者开始使用它来管理数据。而在实际开发中,我们经常需要将数据导出到本地文件或从本地文件导入数据到数据库中。为了更方便地实现这些功能,可以使用ReactQuery数据库插件。ReactQuery数据库插件提供了一系列方

如何使用Power Query将数据拆分为NTFS如何使用Power Query将数据拆分为NTFSMar 15, 2024 am 11:00 AM

本文将介绍如何使用PowerQuery将数据进行行拆分。在从其他系统或源导出数据时,常常会遇到数据存储在单元格中组合多个值的情况。通过PowerQuery,我们可以轻松将这样的数据拆分成行,使得数据更易于处理和分析。若用户不了解Excel的规则并意外将多个数据输入到一个单元格,或者在从其他来源复制/粘贴数据时未正确格式化,就会出现这种情况。要处理这些数据,需要额外的步骤来提取和整理信息,以便进行分析或报告。如何在PowerQuery中拆分数据?PowerQuery转换可以根据各种不同因素(例如字

React Query 数据库插件:实现数据备份和还原的策略React Query 数据库插件:实现数据备份和还原的策略Sep 28, 2023 pm 11:22 PM

ReactQuery数据库插件:实现数据备份和还原的策略,需要具体代码示例引言:在现代的Web开发中,数据的备份和还原是非常重要的一项任务。特别是在使用ReactQuery这样的状态管理工具时,我们需要确保数据的安全性和可靠性。本文将介绍一种基于ReactQuery的数据库插件,用于实现数据备份和还原的策略,并提供具体的代码示例。ReactQu

React Query 数据库插件:实现数据压缩和解压缩的技巧React Query 数据库插件:实现数据压缩和解压缩的技巧Sep 26, 2023 pm 08:03 PM

ReactQuery数据库插件:实现数据压缩和解压缩的技巧,需要具体代码示例引言:在现代Web应用开发中,处理大量的数据查询是一项常见的任务。ReactQuery是一个强大的库,提供了简单、直观的方式来管理数据查询和状态。尽管ReactQuery本身已经非常优秀,但当处理大量数据时,我们可能需要考虑一些额外的技巧来提高性能和优化存储空间。本文将介绍

基于知识增强和预训练大模型的 Query 意图识别基于知识增强和预训练大模型的 Query 意图识别May 19, 2023 pm 02:01 PM

一、背景介绍企业数字化是近年来很热的一个话题,它是指运用人工智能、大数据、云计算等新一代数字技术,改变企业的业务模式,从而推动企业业务产生新的增长。企业数字化一般来说包括业务经营的数字化和企业管理的数字化。本次分享主要介绍企业管理层面的数字化。信息数字化,简单来说,就是把信息用数字化的方式进行读写、存储和传递。从以前的纸质文档到现在的电子文档以及在线协同文档,信息数字化已经变成了现在办公的新常态。目前阿里使用钉钉文档和语雀文档进行业务协同,在线文档数量已经达到了2000万以上。另外很多企业内部会

Linux系统Apache优化与防盗链详细教程Linux系统Apache优化与防盗链详细教程Feb 20, 2024 am 09:00 AM

以下是关于Linux系统下Apache优化和防盗链的详细教程:Apache性能优化:启用压缩:在Apache配置文件中启用Gzip压缩来减小传输数据的大小。LoadModuledeflate_modulemodules/mod_deflate.soAddOutputFilterByTypeDEFLATEtext/htmltext/plaintext/xmltext/cssapplication/javascript

React Query 数据库插件:实现数据合并和拆分的策略React Query 数据库插件:实现数据合并和拆分的策略Sep 26, 2023 am 09:01 AM

ReactQuery数据库插件:实现数据合并和拆分的策略,需要具体代码示例标题:ReactQuery数据库插件:实现数据合并和拆分的策略引言:在现代的Web开发中,数据请求和管理是非常重要的一环。ReactQuery是React生态系统中一款非常受欢迎的数据查询和管理库,它提供了一种简洁的方式来管理应用中的数据请求、缓存和状态,同时与Rea

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
Repo: How To Revive Teammates
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

DVWA

DVWA

Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

PhpStorm Mac version

PhpStorm Mac version

The latest (2018.2.1) professional PHP integrated development tool

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

MinGW - Minimalist GNU for Windows

MinGW - Minimalist GNU for Windows

This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

ZendStudio 13.5.1 Mac

ZendStudio 13.5.1 Mac

Powerful PHP integrated development environment