note 95589 deleted from function.in-array by thiago
| From: | thiago@php.net | Date: | Mon, 11 Jan 2010 11:27:31 +0000 |
| Subject: | note 95589 deleted from function.in-array by thiago | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-164843@lists.php.net to get a copy of this message | ||
Note Submitter: omar
----
Im seeking a solution to check for duplicate entries with an other sequence
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?