954,597 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

how can i get the percentage of difference between two strings?

hi guys, how can i get the difference between two strings in PHP?
i mean lets say string 1 = "hello world"
and string 2 = "Hello World"
the php code should compare these two strings and output something like:
the difference between the two strings is 20%...

so how can i do this???

the prince Awah
Junior Poster
162 posts since Jul 2010
Reputation Points: 5
Solved Threads: 1
 
pritaeas
Posting Expert
Moderator
5,484 posts since Jul 2006
Reputation Points: 653
Solved Threads: 875
 

PHP has a number of functions - as shown by Pritaeas' link, but you need to set rules for the comparison, as it can get quite complicated. Case sensitive - OK. How would you do the following:

"Hello World Says Me" | "I Said Hello My World Hello"

What sort of %age would you return for this with your rules?

diafol
Rhod Gilbert Fan (ardav)
Moderator
7,796 posts since Oct 2006
Reputation Points: 1,170
Solved Threads: 1,080
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: