Im seeking a solution to check for duplicate entries with an other sequence
| From: | omar zorgui | Date: | Mon, 11 Jan 2010 11:04:04 +0000 |
| Subject: | Im seeking a solution to check for duplicate entries with an other sequence | ||
| Groups: | php.db | ||
| Request: | Send a blank email to php-db+get-46771@lists.php.net to get a copy of this message | ||
Hello,
I have a question currently i'm programming a function to remove duplicates
from an array of sentences.
The computer must classify sentences with exactly the same words in it, but
with a different sequence as a duplicate.
The array that i use as a feed is as following:
$sentences[] = "this is a example sentence";
$sentences[] = "a this is example sentence";
$sentences[] = "example this is a sentence";
$sentences[] = "this is a example sentence for a function";
I want the computer to keep only two records of the sentence array in this
case (0|1|2) and 3
I made the script as following:
function($sentences) {
foreach($sentences as $sentence) {
$words = explode(" ",$sentence);
$sentenceArray[] = $words;
}
foreach(sentenceArray as $sentence) {
// Here i want the same words are in other sentences
}
}
My question is how could i check the $sentence array if there are records in
it with exactly the same words
as my feed?