X-Git-Url: http://git.harvie.cz/?a=blobdiff_plain;f=smarty%2FSmarty-2.6.10%2Flibs%2Fplugins%2Fmodifier.count_words.php;fp=smarty%2FSmarty-2.6.10%2Flibs%2Fplugins%2Fmodifier.count_words.php;h=42c8a741c5cdd6754dc3f18b4e83f56b0e990408;hb=b42b2bf946332ad8544d53f610be9cb05e80bf56;hp=0000000000000000000000000000000000000000;hpb=e586807dafc64c3fe152ab518599e6cf3f0f84e1;p=mirrors%2FKyberia-bloodline.git diff --git a/smarty/Smarty-2.6.10/libs/plugins/modifier.count_words.php b/smarty/Smarty-2.6.10/libs/plugins/modifier.count_words.php new file mode 100644 index 0000000..42c8a74 --- /dev/null +++ b/smarty/Smarty-2.6.10/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: */ + +?>