From 588727c7e2b8954ec3dbde293cf4c4d68b119f9b Mon Sep 17 00:00:00 2001 From: xue <> Date: Mon, 19 Jun 2006 18:38:29 +0000 Subject: Merge from 3.0 branch till 1185. --- .../libs/plugins/modifier.count_words.php | 32 ++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 buildscripts/PhpDocumentor/phpDocumentor/Smarty-2.6.0/libs/plugins/modifier.count_words.php (limited to 'buildscripts/PhpDocumentor/phpDocumentor/Smarty-2.6.0/libs/plugins/modifier.count_words.php') diff --git a/buildscripts/PhpDocumentor/phpDocumentor/Smarty-2.6.0/libs/plugins/modifier.count_words.php b/buildscripts/PhpDocumentor/phpDocumentor/Smarty-2.6.0/libs/plugins/modifier.count_words.php new file mode 100644 index 00000000..a686e4b4 --- /dev/null +++ b/buildscripts/PhpDocumentor/phpDocumentor/Smarty-2.6.0/libs/plugins/modifier.count_words.php @@ -0,0 +1,32 @@ + + * Name: count_words
+ * Purpose: count the number of words in a text + * @link http://smarty.php.net/manual/en/language.modifier.count.words.php + * count_words (Smarty online manual) + * @param string + * @return integer + */ +function smarty_modifier_count_words($string) +{ + // split text by ' ',\r,\n,\f,\t + $split_array = preg_split('/\s+/',$string); + // count matches that contain alphanumerics + $word_count = preg_grep('/[a-zA-Z0-9\\x80-\\xff]/', $split_array); + + return count($word_count); +} + +/* vim: set expandtab: */ + +?> -- cgit v1.2.3