String matching problem: please kindly advise. $ A = "1, 2, 3, 4, 5"
$ B = "1, 2, 3, 4, 6"
$ C = "1, 2, 4, 5, 6"
$ D = "2, 3, 4, 5, 6"
$ F = "7, 8, 9, 10, 11"
How can we determine the similarity between $ B, $ c, $ d, $ f and $? Then, determine their percentage.
Reply to discussion (solution)
Come and help
Prerequisites:
1. sharding
2. the number after splitting must be the same
3. do not perform sequential comparison
Function similarity ($ a, $ B) {$ a_arr = explode (',', $ a); $ B _arr = explode (',', $ B ); $ num = count (array_intersect ($ a_arr, $ B _arr); $ count = count ($ a_arr); return ($ num/$ count * 100 ). '%';} $ a = "1, 2, 3, 4, 5"; $ B = "1, 2, 3, 4, 6"; $ c = "1, 2, 4, 5, 6 "; $ d = "2, 3, 4, 5, 6"; $ f = "7, 8, 9, 10, 11"; echo similarity ($ a, $ B ).'
'; Echo similarity ($ a, $ c ).'
'; Echo similarity ($ a, $ d ).'
'; Echo similarity ($ a, $ f ).'
';
Thanks. I also found this function last night.
Php comes with a similar one. I want to extract user choices from the database and match them with other users. Hey