Author: gpupo
Date: 2010-03-06 05:45:04 +0100 (Sat, 06 Mar 2010)
New Revision: 28403
Added:
plugins/sfG1mrToolsPlugin/lib/
plugins/sfG1mrToolsPlugin/lib/sfG1mrToolsString.class.php
Log:
start
Added: plugins/sfG1mrToolsPlugin/lib/sfG1mrToolsString.class.php
===================================================================
--- plugins/sfG1mrToolsPlugin/lib/sfG1mrToolsString.class.php
(rev 0)
+++ plugins/sfG1mrToolsPlugin/lib/sfG1mrToolsString.class.php 2010-03-06
04:45:04 UTC (rev 28403)
@@ -0,0 +1,33 @@
+<?php
+
+
+class sfG1mrToolsString
+{
+ static public function slugify($text)
+ {
+ // replace non letter or digits by -
+ $text = preg_replace('~[^\\pL\d]+~u', '-', $text);
+
+ // trim
+ $text = trim($text, '-');
+
+ // transliterate
+ if (function_exists('iconv'))
+ {
+ $text = iconv('utf-8', 'us-ascii//TRANSLIT', $text);
+ }
+
+ // lowercase
+ $text = strtolower($text);
+
+ // remove unwanted characters
+ $text = preg_replace('~[^-\w]+~', '', $text);
+
+ if (empty($text))
+ {
+ return 'n-a';
+ }
+
+ return $text;
+ }
+}
\ No newline at end of file
--
You received this message because you are subscribed to the Google Groups
"symfony SVN" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/symfony-svn?hl=en.