Reply to Re: Keyword array

Your name:

Reply:


Posted by Rik on 08/15/06 15:36

Karl Groves wrote:
> I'm looking to make a keyword array.
>
> Let's say I have the following array:
>
> $words = array
>
("foo","lorem","foo","ipsum","bar","foo","dolor","sit","foo","bar","amet","
> lorem");
>
> I'd like to create a new array with the top X words, ordered by
> occurrence In the above example, the new array would be:
> $keywords = array("foo","bar","lorem");


I assum the top X words, ordered _descending_?

$number = 10;//or another if you wish
$top = array_slice(array_keys(rsort(array_count_values($words))),0,$number);

If PHP5 or higher this will be better:
$top =
array_keys(array_slice(rsort(array_count_values($words)),0,$number,true));

Grtz,
--
Rik Wasmus

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация