hi please slove my problem in php,
- user input from form textarea is -->ex:text1="Admanya, India's first consumer education cum advocacy website listens to the consumers and not just hear them. Admanya is the best platform for consumers to voice their opinions, compare the product features and service quality, read user reviews, build relationships through interactive exchanges, and get detailed product information about different brands. You can also create your own space through profile, blogs, discussion and comments";
2.php file
//database table:
CREATE TABLE php1db.words_eliminate (
id int(5) NOT NULL auto_increment,
words varchar(25) default NULL,
PRIMARY KEY (id)
);
and the table contains values:
id words
1 admanya
2 to
3 and
4 about
5 amp
6 and
7 at
8 first
my requirement is to exclude the above words from the database and the reaming words should be stored in the array.
//database using for getting the words to exclude from the user given text
$con=mysql_connect("local","","");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("phpdb1", $con);
$newarray1=array();
$result = mysql_query("select words from words_eliminate");
while($row = mysql_fetch_array($result))
{
$newarray1[]="@ ".$row['words']." @" ;
}
mysql_close($con);
//triming the user given value first
$s=trim($_POST['text1']);
//i have to exclude the following words in the user given string for that i'm using below variable and storing in array those
$exclude_words1 =$newarray1;
$s = preg_replace($exclude_words1, ' ', $s);
$exclude_symbs = array('@[0-9]@','@.@','@\,@','@:@','@"@','@\?@','@(@','@)@','@!@','@\/@','@\&@','@\ @');
$s = preg_replace($exclude_symbs, ' ', $s); // Strip excluded symbols
$s = preg_replace($exclude_words1, ' ', $s); // Strip excluded words
//spiting the user given input into seperate words and storing them as array
$words = array_count_values(explode(' ',strtolower($s)));
print_r($words);
?>
from the above code i have to get only the words which are not in th excluded list..but from the above code i'm getting some of the excluded words also pls slove this..i.e its not excluding some of the words
pls give the solution