Looking for a script to find keywords in text

Discussion in 'PHP' started by the_j0ker, Nov 5, 2007.

  1. #1
    Does anyone know of free script that takes a text string as input and gives the keywords found in that string as output?

    TIA :)
     
    the_j0ker, Nov 5, 2007 IP
  2. nico_swd

    nico_swd Prominent Member

    Messages:
    4,153
    Likes Received:
    344
    Best Answers:
    18
    Trophy Points:
    375
    #2
    
    function fetch_keywords()
    {
    	$keywords = func_get_args();
    	$text = array_shift($keywords);
    	$keywords = array_map('preg_quote', $keywords);
    
    	return preg_match_all('~(' . implode('|', $keywords) . ')~i', $text, $matches)
    		? $matches[1]
    		: false;
    }
    
    
    
    PHP:
    Example:

    
    
    $found_keywords = fetch_keywords($text, 'keyword1', 'keyword 2', 'keyword3', '...');
    
    PHP:
     
    nico_swd, Nov 5, 2007 IP