Re: string comparison on numerical array
| From: | Brian Clark | Date: | Fri, 10 Nov 2000 15:08:05 +0000 |
| Subject: | Re: string comparison on numerical array | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-24658@lists.php.net to get a copy of this message | ||
Adrian Murphy wrote:
I use the explode() function to split an article into words.so each element in the array is a word.how can i then do a string comparsion on this array to match a keyword provided in a search. i.e<?php function php3_in_array($string, $array) { while(list($i,) = each($array)) {
if($array[$i] == $string) return true;} } ?> with PHP 3.x, or in_array() with PHP 4.x http://www.php.net/manual/html/function.in-array.html
$article[$i] = $keyword;print in_array($keyword, $article) ? 'Yes' : 'No';
so $keyword is provided and i need to get the value of $i. i'm doing this in order to display a snippet or snippets of text containing the keyword. thanx.-Brian