Posted By

chopbust on 03/03/11


Tagged


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

uberdragon


Compare 2 set of strings and get percentage of Match


 / Published in: PHP
 

Get percentage of how much 2 strings matches with each other. Good for comparing things that doesn't have to be an exact match to fit.

  1. $str1 = ereg_replace("[^A-Za-z0-9]", "", $str1);
  2. $str2 = ereg_replace("[^A-Za-z0-9]", "", $str2);
  3. similar_text($str1, $str2, $percent);
  4. //$percent = how much they match!

Report this snippet  

You need to login to post a comment.