Mercurial > defr > DualBlog
annotate 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 |
rev | line source |
---|---|
webmaster@0 | 1 <?php |
webmaster@0 | 2 class TextUtils |
webmaster@0 | 3 { |
webmaster@0 | 4 public static function SplitTags($str) |
webmaster@0 | 5 { |
webmaster@0 | 6 $str = str_replace("\\\"", "\"", $str); |
webmaster@0 | 7 $tags = array(); |
webmaster@0 | 8 preg_match_all('/"([a-zA-Z0-9 ]+)"/', $str, $tests); |
webmaster@0 | 9 $useful = $tests[1]; |
webmaster@0 | 10 foreach($useful as $match) |
webmaster@0 | 11 { |
webmaster@0 | 12 $tags[] = $match; |
webmaster@0 | 13 $str = str_replace("\"{$match}\"", null, $str); |
webmaster@0 | 14 } |
webmaster@0 | 15 $str = preg_replace("/( )+/", " ", trim($str)); |
webmaster@0 | 16 if(strlen($str) > 0) |
webmaster@0 | 17 $tags = array_merge($tags, explode(" ", $str)); |
webmaster@0 | 18 asort($tags); |
webmaster@0 | 19 return $tags; |
webmaster@0 | 20 } |
webmaster@0 | 21 |
webmaster@0 | 22 public static function DiffTagLine($old, $new, &$ajout, &$suppr) |
webmaster@0 | 23 { |
webmaster@0 | 24 $arOld = TextUtils::SplitTags($old); |
webmaster@0 | 25 $arNew = TextUtils::SplitTags($new); |
webmaster@0 | 26 $ajout = array_diff($arNew, $arOld); |
webmaster@0 | 27 $suppr = array_diff($arOld, $arNew); |
webmaster@0 | 28 } |
webmaster@0 | 29 } |
webmaster@0 | 30 ?> |