Page 1 of 1

Removing a value from an array

Posted: Mon Nov 14, 2005 5:16 am
by hame22
Hi all

I have built my own search engine to search my site for resources.

It takes the search terms from the text box and then breaks the phrase into its individual words which I then search on and base relevancy upon.

Code: Select all

$q_array=explode(" ", $q);

	//count how many keywords there are
	$q_num=(integer)count($q_array);
	
	$r = query_table($q_num, $q_array, $cat);
the problem is it takes all words including common words such as "and", "a" etc.

what I would like to do is remove these type of words if they arise.

How would i go about removing these from the array before I pass it onto my listing function??

thanks in advance

Posted: Mon Nov 14, 2005 6:39 am
by twigletmac
You can setup an array of excluded words and then use array_diff() to create a new array from the collected words which excludes those excluded words.

Mac