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