diff --git a/digital_doctor/vendor/wanghua/general-utility-tools-php/src/tool/Tools.php b/digital_doctor/vendor/wanghua/general-utility-tools-php/src/tool/Tools.php index c605758..8b75c78 100644 --- a/digital_doctor/vendor/wanghua/general-utility-tools-php/src/tool/Tools.php +++ b/digital_doctor/vendor/wanghua/general-utility-tools-php/src/tool/Tools.php @@ -2386,4 +2386,21 @@ FROM information_schema.columns WHERE TABLE_NAME='{$tablename}' AND table_schema $ver = substr($str,0,3); return $ver; } + + /** + * desc:根据字符串生成颜色码 + * author:wh + * @param $string + * @return string + */ + static function stringToColor($string) { + // 使用crc32函数计算字符串的哈希值 + $hash = crc32($string); + + // 将整数哈希值转换为16进制,并填充0以确保6位长度 + $color = sprintf("%06X", $hash & 0xFFFFFF); + + // 返回颜色码 + return '#' . $color; + } } \ No newline at end of file