note 95589 added to function.in-array

From: Date: Mon, 11 Jan 2010 11:20:40 +0000
Subject: note 95589 added to function.in-array
Groups: php.notes 
Request: Send a blank email to php-notes+get-164842@lists.php.net to get a copy of this message
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? ---- Server IP: 69.147.83.197 Probable Submitter: 194.123.36.165 ---- Manual Page -- http://www.php.net/manual/en/function.in-array.php Edit -- https://master.php.net/note/edit/95589 Del: integrated -- https://master.php.net/note/delete/95589/integrated Del: useless -- https://master.php.net/note/delete/95589/useless Del: bad code -- https://master.php.net/note/delete/95589/bad+code Del: spam -- https://master.php.net/note/delete/95589/spam Del: non-english -- https://master.php.net/note/delete/95589/non-english Del: in docs -- https://master.php.net/note/delete/95589/in+docs Del: other reasons-- https://master.php.net/note/delete/95589 Reject -- https://master.php.net/note/reject/95589 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#164842) next »