codepad
[
create a new paste
]
login
|
about
Language:
C
C++
D
Haskell
Lua
OCaml
PHP
Perl
Plain Text
Python
Ruby
Scheme
Tcl
<?php function processContent($content, $min_count = 2, $exclude_list = array()) { $wordsTmp = explode(' ', str_replace(array('(', ')', '[', ']', '{', '}', "'", '"', ':', ',', '.', '?'), ' ', $content)); $words = array(); $wordsTmp2 = array(); $omit = array('and', 'or', 'but', 'yet', 'for', 'not', 'so', '&', '&', '+', '=', '-', '*', '/', '^', '_', '\\', '|'); if(count($exclude_list)>0){ $omit = array_merge($omit, $exclude_list); } foreach ($wordsTmp as $wordTmp) { $wordTmp = trim(stripslashes($wordTmp)); while (substr($wordTmp, strlen($wordTmp) - 1) == ".") { $wordTmp = substr($wordTmp, 0, strlen($wordTmp) - 2); } while (substr($wordTmp, 0, 1) == ".") { $wordTmp = substr($wordTmp, 1); } $wordTmp = strtolower($wordTmp); $wordsTmp2[] = $wordTmp; if (!empty($wordTmp) && !in_array($wordTmp, $omit) && strlen($wordTmp) >= $min_count) { $words[] = $wordTmp; } } return $words; } $word_list = "a for of ok"; $filter_array = explode("\n", $word_list); print_r($filter_array); print_r(processContent("of for what k vancha yo", 2, $filter_array));
Private
[
?
]
Run code
Submit