aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorMaZderMind2016-12-21 18:22:37 +0100
committerMaZderMind2016-12-21 18:22:37 +0100
commitdbed89499b93b2ec3c2c50e5805ef8393a8ef990 (patch)
treee5cf08a010816b24932b29e6778ae53181b743b9 /lib
parentafde5288d747f4899a560d304cb5294b36c7d051 (diff)
work on startpage style
Diffstat (limited to 'lib')
-rw-r--r--lib/helper.php27
1 files changed, 27 insertions, 0 deletions
diff --git a/lib/helper.php b/lib/helper.php
index 1925382..67c84aa 100644
--- a/lib/helper.php
+++ b/lib/helper.php
@@ -145,3 +145,30 @@ function array_filter_last($array, $predicate)
return null;
}
+
+function slugify($text)
+{
+ // replace non letter or digits by -
+ $text = preg_replace('~[^\pL\d]+~u', '-', $text);
+
+ // transliterate
+ $text = iconv('utf-8', 'us-ascii//TRANSLIT', $text);
+
+ // remove unwanted characters
+ $text = preg_replace('~[^-\w]+~', '', $text);
+
+ // trim
+ $text = trim($text, '-');
+
+ // remove duplicate -
+ $text = preg_replace('~-+~', '-', $text);
+
+ // lowercase
+ $text = strtolower($text);
+
+ if (empty($text)) {
+ return 'none';
+ }
+
+ return $text;
+}