00001 <?php 00021 function smarty_modifier_count_words($string) 00022 { 00023 // split text by ' ',\r,\n,\f,\t 00024 $split_array = preg_split('/\s+/',$string); 00025 // count matches that contain alphanumerics 00026 $word_count = preg_grep('/[a-zA-Z0-9\\x80-\\xff]/', $split_array); 00027 00028 return count($word_count); 00029 } 00030 00031 /* vim: set expandtab: */ 00032 00033 ?>