찾다
php教程php手册php比较相似字符串的方法

php比较相似字符串的方法

Jun 13, 2016 am 09:02 AM
php공유하다방법비교하다~의유사

php比较相似字符串的方法

   本文实例讲述了php比较相似字符串的方法。分享给大家供大家参考。具体分析如下:

  这里通过php的similar_text函数比较两个字符串的相似性。

  ?

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

$word2compare = "stupid";

$words = array(

'stupid',

'stu and pid',

'hello',

'foobar',

'stpid',

'upid',

'stuuupid',

'sstuuupiiid',

);

while(list($id, $str) = each($words)){

similar_text($str, $word2compare, $percent);

print "Comparing '$word2compare' with '$str': ";

print round($percent) . "%\n";

}

/*

Results:

Comparing 'stupid' with 'stupid': 100%

Comparing 'stupid' with 'stu and pid': 71%

Comparing 'stupid' with 'hello': 0%

Comparing 'stupid' with 'foobar': 0%

Comparing 'stupid' with 'stpid': 91%

Comparing 'stupid' with 'upid': 80%

Comparing 'stupid' with 'stuuupid': 86%

Comparing 'stupid' with 'sstuuupiiid': 71%

*/

  希望本文所述对大家的php程序设计有所帮助。

성명
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.

핫 AI 도구

Undresser.AI Undress

Undresser.AI Undress

사실적인 누드 사진을 만들기 위한 AI 기반 앱

AI Clothes Remover

AI Clothes Remover

사진에서 옷을 제거하는 온라인 AI 도구입니다.

Undress AI Tool

Undress AI Tool

무료로 이미지를 벗다

Clothoff.io

Clothoff.io

AI 옷 제거제

Video Face Swap

Video Face Swap

완전히 무료인 AI 얼굴 교환 도구를 사용하여 모든 비디오의 얼굴을 쉽게 바꾸세요!

뜨거운 도구

드림위버 CS6

드림위버 CS6

시각적 웹 개발 도구

WebStorm Mac 버전

WebStorm Mac 버전

유용한 JavaScript 개발 도구

VSCode Windows 64비트 다운로드

VSCode Windows 64비트 다운로드

Microsoft에서 출시한 강력한 무료 IDE 편집기

SublimeText3 Mac 버전

SublimeText3 Mac 버전

신 수준의 코드 편집 소프트웨어(SublimeText3)

맨티스BT

맨티스BT

Mantis는 제품 결함 추적을 돕기 위해 설계된 배포하기 쉬운 웹 기반 결함 추적 도구입니다. PHP, MySQL 및 웹 서버가 필요합니다. 데모 및 호스팅 서비스를 확인해 보세요.