我是初学者,当谈到编程时,我想看看这是否是正确的编码方式。我试图从数组中生成随机背景颜色。阵列的随机背景颜色 - PHP
如果有什么我失踪或有什么我可以做得更好请让我知道。
<?php
$background_colors = array('#282E33', '#25373A', '#164852', '#495E67', '#FF3838');
$count = count($background_colors) - 1;
$i = rand(0, $count);
$rand_background = $background_colors[$i];
?>
<html>
<head>
</head>
<body style="background: <?php echo $rand_background; ?>;">
</body>
</html>
啊好吧,我一直在寻找该功能,但不知道如何使用它。谢谢。 – 2012-03-08 02:32:22