comparison includes/class.textutils.php @ 0:629389204276

Import initial
author Franck Deroche <webmaster@defr.org>
date Sat, 20 Oct 2007 14:15:10 +0200
parents
children 8f1125d27079
comparison
equal deleted inserted replaced
-1:000000000000 0:629389204276
1 <?php
2 class TextUtils
3 {
4 public static function SplitTags($str)
5 {
6 $str = str_replace("\\\"", "\"", $str);
7 $tags = array();
8 preg_match_all('/"([a-zA-Z0-9 ]+)"/', $str, $tests);
9 $useful = $tests[1];
10 foreach($useful as $match)
11 {
12 $tags[] = $match;
13 $str = str_replace("\"{$match}\"", null, $str);
14 }
15 $str = preg_replace("/( )+/", " ", trim($str));
16 if(strlen($str) > 0)
17 $tags = array_merge($tags, explode(" ", $str));
18 asort($tags);
19 return $tags;
20 }
21
22 public static function DiffTagLine($old, $new, &$ajout, &$suppr)
23 {
24 $arOld = TextUtils::SplitTags($old);
25 $arNew = TextUtils::SplitTags($new);
26 $ajout = array_diff($arNew, $arOld);
27 $suppr = array_diff($arOld, $arNew);
28 }
29 }
30 ?>