Forum Moderators: coopster

Message Too Old, No Replies

PHP in array issue

unable to search a word in an array

         

tabish

12:17 pm on Jan 8, 2007 (gmt 0)

10+ Year Member



Hello,

I have an array

$commonwords = array ("and", "he", "I", "in", "is", "it", "of", "that", "the", "to", "was","are", "as", "at", "be", "but", "for", "had", "have", "him","his", "not", "on", "one", "said", "so", "they", "we", "with", "you", "about", "an", "back", "been", "before", "big", "by", "call","came", "can", "come", "could", "did", "do", "down", "first", "from", "get", "go","has", "her", "here", "if", "into", "just", "like", "little", "look", "made", "make","more", "me", "much", "must", "my", "no", "new", "now", "off", "old", "only", "or","our", "other", "out", "over", "right", "she", "see", "some", "their", "them", "then","there", "this", "two", "up", "want", "well", "went", "were", "what", "when", "where","which", "who", "will", "your", "i", "&", "a", "good", "i'm");

Now I am trying to check if a perticuler search word containing any word which is in array.. so avoide them.. example:

if(!in_array($space_split['search_word'],$commonwords))
{
// some work
}

this is not giving me right result.. for example.. it is not avoiding some words like "a" "i'm" "&" and few others..

can anyone tell me what is this issue?

thank you so cuh..

regards
tabish
{

hughie

12:40 pm on Jan 8, 2007 (gmt 0)

10+ Year Member



Make sure your input is what you expect, if it's coming from a form then 's and &'s could come in as &amp or similar.

Also make everything lower case using strtolower.

tabish

1:55 pm on Jan 8, 2007 (gmt 0)

10+ Year Member



thnx dude..

it was "New Lines" making me nuts..

now it is fine..

thank you again