Jump to content

similar_text between two arrays?


Kane250

Recommended Posts

Can anyone provide an example of how I might use similar_text between two arrays?  I want to take one array of entries, and look for matches in an array from MySQL that are within a certain % of similarity so that I can remove those entries before inserting into MySQL.  I can't find a single example online that compares two arrays with this function.

 

Any help is really appreciated.  I really need to figure this out ASAP. even if you could just explain the logic of how I would have to write it!

 

Thanks!

Link to comment
https://forums.phpfreaks.com/topic/154289-similar_text-between-two-arrays/
Share on other sites

Here is an example of what I'm working with..I know it's totally wrong, but I'm just trying anything right now..

 

$unique_entries (

    0=> "one sentence",

    1=> "second sentence",

 

$compare_array (

    0=> "a second sentence",

    1=> "one sentence",

 

else {
	print "we are at else";
	foreach ($unique_entries as $testagainst){
		foreach ($compare_array as $database_entries) {
		similar_text($test_against, $database_entries, $how_similar)
			if ($how_similar < 75) {
				$unique_entries[] = $test_against;
			}
		}
	}

 

Ideally in this example, it would not pass either, even though "second sentence" is not the same as "a second sentence" because of such close similarity from the array connected to the database.

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.