Re: Re: keywords generation

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Finally a solution for those who needs! :)

==================================FUNCTION============================== ====
function generate_keywords($text,$number=10)
{
$iwords = array('a',
'to',
'of',
't',
'e'
);


if(isset($text) && $text != '' && $text=strtolower($text))
{
foreach($iwords as $var=>$val)
{
$text = str_replace($val,'',$text);
}

foreach(str_word_count($text,2) as $var=>$val)
{
$total[$val] = substr_count($text,$val);
}

arsort($total,SORT_NUMERIC);

return implode(',',array_keys(array_slice($total, 0, $number)));
}
}
==================================EXAMPLE=============================== ===
$submited_text = 'Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat. Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit augue duis dolore te feugait nulla facilisi. ';


echo generate_keywords($submited_text);
======================================================================== ====


Thanks to Tularis and Sokolewicz .

Regards,
Bruno B B Magalhães
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux