Add function for converting strings to color codes
This commit is contained in:
1 file changed
+14
+14
@@ -465,4 +465,18 @@ public static function levenshtein(string $str1, string $str2):int {
|
|||||||
return \levenshtein($str1, $str2);
|
return \levenshtein($str1, $str2);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Converts a string to color codes.
|
||||||
|
*
|
||||||
|
* @param string $str Input string.
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public static function string_to_color_code(string $str):string {
|
||||||
|
|
||||||
|
$code = substr(dechex(crc32($str)), 0, 6);
|
||||||
|
return $code;
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user