changed git call from https to git readonly
[atutor.git] / mods / phpdoc2 / PhpDocumentor / phpDocumentor / Smarty-2.6.0 / libs / plugins / modifier.count_words.php
1 <?php\r
2 /**\r
3  * Smarty plugin\r
4  * @package Smarty\r
5  * @subpackage plugins\r
6  */\r
7 \r
8 \r
9 /**\r
10  * Smarty count_words modifier plugin\r
11  *\r
12  * Type:     modifier<br>\r
13  * Name:     count_words<br>\r
14  * Purpose:  count the number of words in a text\r
15  * @link http://smarty.php.net/manual/en/language.modifier.count.words.php\r
16  *          count_words (Smarty online manual)\r
17  * @param string\r
18  * @return integer\r
19  */\r
20 function smarty_modifier_count_words($string)\r
21 {\r
22     // split text by ' ',\r,\n,\f,\t\r
23     $split_array = preg_split('/\s+/',$string);\r
24     // count matches that contain alphanumerics\r
25     $word_count = preg_grep('/[a-zA-Z0-9\\x80-\\xff]/', $split_array);\r
26 \r
27     return count($word_count);\r
28 }\r
29 \r
30 /* vim: set expandtab: */\r
31 \r
32 ?>\r