之前做随机色标签云都是用JS写的,JS写就是有个问题,太消耗服务器了,每次刷新的颜色也都不一样。今天发现了用PHP制作随机色标签云的代码,分享给大家,学会了可以套用到各种地方。
效果图演示
PHP制作随机色标签云代码
<? srand((float) microtime() * 10000000); $input = array("8b90c4","ee96e","81fa17","f81","aab80a","de11a5","2d0705","c4de05","1b7ef7","84b6b2","2ca94b","3e383f","5d73c1","a317ad","4ffafa","696f3e","e7aa89","a5b575","19c9ed","70e46c","7d4fa","62caaa","d1f484","795a1a","daf143","581cba","c99bac","3a2fb4","f725dc","7722f0","d79bd3","82b6a0","860c5e","5995ea","82c622","30c469","37a78f","afcd27","f5a26e","532687","3483da","224bb9","915ec7","91f79b","c56367"); $rand_keys = array_rand($input, 2); $input1 = array("8","13","12"); $rand_f = array_rand($input1, 2); echo '<a target="_blank" href="#" style="color:#'.$input[$rand_keys[0]].';font-size: '.$input1[$rand_f[0]].'pt;;">'.$bqr['tagname'].'</a>'; ?>
代码中的array里面的字符串就是各种随机色的编码,大家可以根据自己的需求来配置颜色。
然后input1里面是字体大小的随机代码,也可以自行修改。
资源均来自第三方,谨慎下载,前往第三方网站下载