source: spip-zone/_squelettes_/soyezcreateurs_net/trunk/plugins/soyezcreateurs/comptetraduction_fonctions.php @ 105698

Last change on this file since 105698 was 105698, checked in by real3t@…, 22 months ago

Utiliser textebrut pour ne pas compter le HTML !

Un lien pour récupérer l'ensemble des textes d'un coup (pour coller dans un traitement de texte...)

File size: 558 bytes
Line 
1
2<?php
3
4/***
5* This simple utf-8 word count function (it only counts)
6* is a bit faster then the one with preg_match_all
7* about 10x slower then the built-in str_word_count
8*
9* If you need the hyphen or other code points as word-characters
10* just put them into the [brackets] like [^\p{L}\p{N}\'\-]
11* If the pattern contains utf-8, utf8_encode() the pattern,
12* as it is expected to be valid utf-8 (using the u modifier).
13**/
14
15// Jonny 5's simple word splitter
16function str_word_count_utf8($str) {
17  return count(preg_split('~[^\p{L}\p{N}\']+~u',$str));
18}
19?>
Note: See TracBrowser for help on using the repository browser.