note 52993 deleted from function.array-unique by nlopess
| From: | nlopess@php.net | Date: | Sat, 24 Nov 2007 11:30:30 +0000 |
| Subject: | note 52993 deleted from function.array-unique by nlopess | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-132530@lists.php.net to get a copy of this message | ||
Note Submitter: cdblog at gmail dot com
----
<?php
/**
* @param string
* @return array
* @author Cocol
* @desc generate unique keywords
* for more detail please visit http://php.clickz.cn/articles/array/array_unique.html
*/
function keyword_unique($url = "") {
$unique = array(
'words' => array(),
'times' => array(),
);
$buffer = @file_get_contents($url);
$words1 = str_word_count(strtolower(strip_tags($buffer)),1);
$unique['words'] = array_unique($words1);
foreach ($words1 as $key=>$val) {
if (!in_array($val,$unique['words'])) {
$unique['times'][] = 1;
} else {
$i = array_search($val,$unique['words']);
$unique['times'][$i] += 1;
}
}
array_multisort($unique['times'],SORT_DESC,$unique['words']);
return $unique;
}
$keywords = keyword_unique("http://php.clickz.cn/");
print_r($keywords);
?>