Random color generation using PHP

前端 未结 13 1792
终归单人心
终归单人心 2020-12-14 09:48

I\'m trying to generate random HTML colors in PHP, but I\'m having trouble getting them to look similar, or in the same family. Is there some function I can use to generate

13条回答
  •  失恋的感觉
    2020-12-14 10:30

    Try this:

    //For every hex code
    $random = mt_rand(0, 16777215);
    $color = "#" . dechex($random);
    

    And than you can just use it like this:

    background-color: ;
    

提交回复
热议问题