PHP 随机生成十六进制颜色代码

function xmsb_randomColor()
{
    $strList = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'];
    $finalColor = '#';
    
    for($i = 0; $i < 6; $i ++)
    {
        $finalColor .= $strList[array_rand($strList)];
    }
    
    return $finalColor;
}

 

posted @ 2021-08-28 17:25  何效名  阅读(143)  评论(0)    收藏  举报