/[cvs]/nfo/php/libs/net.php.smarty/plugins/modifier.count_words.php
ViewVC logotype

Annotation of /nfo/php/libs/net.php.smarty/plugins/modifier.count_words.php

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1 - (hide annotations)
Wed Oct 9 00:53:36 2002 UTC (21 years, 10 months ago) by cvsjoko
Branch: MAIN
no message

1 cvsjoko 1.1 <?php
2    
3     /*
4     * Smarty plugin
5     * -------------------------------------------------------------
6     * Type: modifier
7     * Name: count_words
8     * Purpose: count the number of words in a text
9     * -------------------------------------------------------------
10     */
11     function smarty_modifier_count_words($string)
12     {
13     // split text by ' ',\r,\n,\f,\t
14     $split_array = preg_split('/\s+/',$string);
15     // count matches that contain alphanumerics
16     $word_count = preg_grep('/[a-zA-Z0-9]/', $split_array);
17    
18     return count($word_count);
19     }
20    
21     /* vim: set expandtab: */
22    
23     ?>

MailToCvsAdmin">MailToCvsAdmin
ViewVC Help
Powered by ViewVC 1.1.26 RSS 2.0 feed