]> git.mxchange.org Git - friendica.git/blobdiff - src/Util/Strings.php
Ensure *toArray returns an array
[friendica.git] / src / Util / Strings.php
index 3f8990d6c124ee268b0de9b10becd1e35adba9d5..88dd1d39f81edd151151dac1ba6b7449528dd871 100644 (file)
@@ -31,6 +31,18 @@ class Strings
         return $return;
     }
 
+       /**
+        * Checks, if the given string is a valid hexadecimal code
+        *
+        * @param string $hexCode
+        *
+        * @return bool
+        */
+    public static function isHex($hexCode)
+    {
+           return !empty($hexCode) ? @preg_match("/^[a-f0-9]{2,}$/i", $hexCode) && !(strlen($hexCode) & 1) : false;
+    }
+
     /**
      * @brief This is our primary input filter.
      *