]> git.immae.eu Git - github/shaarli/Shaarli.git/blobdiff - application/Utils.php
Fixes presence of empty tags for private tags and in search results
[github/shaarli/Shaarli.git] / application / Utils.php
index 62902341aee1a3d2bea676c8bbe3a53a2a721984..35d652241bb6a5a4c42c7ded7b7381be48dc7f15 100644 (file)
@@ -257,3 +257,16 @@ function generate_api_secret($username, $salt)
 
     return str_shuffle(substr(hash_hmac('sha512', uniqid($salt), $username), 10, 12));
 }
+
+/**
+ * Trim string, replace sequences of whitespaces by a single space.
+ * PHP equivalent to `normalize-space` XSLT function.
+ *
+ * @param string $string Input string.
+ *
+ * @return mixed Normalized string.
+ */
+function normalize_spaces($string)
+{
+    return preg_replace('/\s{2,}/', ' ', trim($string));
+}