好!欢迎访问迷津渡口 现在时间是: 天气 °C ~ °C

迷津渡口

越感到迷惑 越接近真理

php获取随机颜色

有时我们需要随机的颜色,如本站的标签背景色,小指分享两种方法。

方法一:完全随机的颜色

<?php
function randColor(){
    $colors = array();
    for($i = 0;$i<6;$i++){
        $colors[] = dechex(rand(0,15));
    }
    return implode('',$colors);
}
?>

使用颜色的方法:

<?php echo '<span style="color: #'.randColor().'">随机颜色:#'.randColor().'</span>';?>

方法二:随机挑选数组里的颜色

<?php
function randColor(){
    $colors=array('5CB85C','428BCA','FF6600','D9534F','B37333','00ABA9');
    $show_color = array_rand($colors, 1);
    return $colors[$show_color];
}
?>

使用颜色的方法是一样的,但是只会是你设置的数组里面的颜色:

<?php echo '<span style="color: #'.randColor().'">随机颜色:#'.randColor().'</span>';?>


需要的自己试试吧~

点赞1
 标签: php获取随机颜色
   支持一下
挤眼 亲亲 咆哮 开心 想想 可怜 糗大了 委屈 哈哈 小声点 右哼哼 左哼哼 疑问 坏笑 赚钱啦 悲伤 耍酷 勾引 厉害 握手 耶 嘻嘻 害羞 鼓掌 馋嘴 抓狂 抱抱 围观 威武 给力
 点赞
 签到
 表情
 图片
 代码
提交评论

清空信息
关闭评论
shipmancomm
 shipmancomm 约 23 小时前回复
#86
<a href="http://www.nedshare.com/adidas-yeezy-boost-350-pirate-sort-bb5350-kit-scarpec">adidas yeezy boost 350 pirate sort bb5350 kit</a> <a href="http://www.njbabyboomer.com/nike-air-max-1-vt-qs-gr%C3%BCn-line-kurpesb">nike air max 1 vt qs gr眉n line</a> <a href="http://www.chipperradio.com/nike-mens-james-develin-limited-olive-jersey-new-england-patriots-nfl-46-2017-salute-to-service-nflr">nike mens james develin limited olive jersey new england patriots nfl 46 2017 salute to service</a> <a href="http://www.danaperth.com/adidas-neo-mesh-marrone-oro-butyg">adidas neo mesh marrone oro</a> <a href="http://www.detabouw.com/miguel-cabrera-florida-marlins-jersey-nflz">miguel cabrera florida marlins jersey</a> <a href="http://www.elyseprather.com/nfl-braden-smith-womens-game-white-jersey-72-indianapolis-colts-nike-road-nflw">nfl braden smith womens game white jersey 72 indianapolis colts nike road</a>
shipmancomm http://www.shipmancomm.com/
clickstroy
 clickstroy 2019-02-15 13:46回复
#85
<a href="http://www.findatrans.com/femminile-nike-air-presto-viola-rosa-scarpej">femminile nike air presto viola rosa</a> <a href="http://www.isabellerigal.com/womens-nike-kyrie-2-grey-sky-blue-shoesh">womens nike kyrie 2 grey sky blue</a> <a href="http://www.esnafkocaeli.com/nike-huarache-utility-hombresta-verde-zapatosk">nike huarache utility hombresta verde</a> <a href="http://www.dkdjabar.com/nike-air-max-tn-p%C3%BArpura-negro-zapatosp">nike air max tn p煤rpura negro</a> <a href="http://www.jamiecirillo.com/north-face-summit-gore-tex-northfaceh">north face summit gore tex</a> <a href="http://www.xpostshopx.com/air-jordan-retro-14-lila-blau-schuhej">air jordan retro 14 lila blau</a>
clickstroy http://www.clickstroy.com/
miembrojr
 miembrojr 2019-02-13 19:24回复
#84
<a href="http://www.cnovas.com/nike-huarache-free-run-industrial-orange-shoesh">nike huarache free run industrial orange</a> <a href="http://www.omnicitycorp.com/nike-kobe-11-rosado-rojo-zapatosp">nike kobe 11 rosado rojo</a> <a href="http://www.cmcheechalk.com/adidas-springblade-ignite-plata-verde-zapatosk">adidas springblade ignite plata verde</a> <a href="http://www.armandopaz.com/north-face-mens-gore-tex-xcr-jacket-light-sea-green-northfaceh">north face mens gore tex xcr jacket light sea green</a> <a href="http://www.alrightdesign.com/aidas-boost-clima-chill-rot-rosa-schuhej">aidas boost clima chill rot rosa</a> <a href="http://www.parksindust.com/nike-air-max-90-premium-s%C3%B8lv-lilla-skoh">nike air max 90 premium s酶lv lilla</a>
miembrojr http://www.miembrojr.com/
sell prada bag
 sell prada bag 2019-02-13 14:03回复
#83
<a href="http://www.ericbigelow.com/rb4165-justin-ray-ban-sunglassesr">rb4165 justin ray ban</a> <a href="http://www.predjimost.com/jacksonville-jaguars-bryan-anger-jersey-19-elite-nike-white-jersey-nfld">jacksonville jaguars bryan anger jersey 19 elite nike white jersey</a> <a href="http://www.blptng.com/mizuno-womens-stability-running-shoes-skot">mizuno womens stability running shoes</a> <a href="http://www.ticketalibi.com/womens-nike-free-run-flyknit-8.5-trainerse">womens nike free run flyknit 8.5</a> <a href="http://www.grtcertified.com/mennns-supra-bleeker-oransje-s%C3%B8lv-chaussuresa">mennns supra bleeker oransje s酶lv</a> <a href="http://www.itechforce.com/yeezy-boost-350-low-volume-footg">yeezy boost 350 low volume</a>
sell prada bag http://www.zipperdude.com/sell-prada-bag-pradar
ifshaildamage
 ifshaildamage 2019-02-13 12:20回复
#82
<a href="http://www.daddeaze.com/new-era-dominican-republic-fitted-hats-black-hata">new era dominican republic fitted hats black</a> <a href="http://www.debracousins.com/nike-flyknit-racer-womens-pink-blue-runninge">nike flyknit racer womens pink blue</a> <a href="http://www.yankaripark.com/air-jordan-10-bleu-gris-schuhea">air jordan 10 bleu gris</a> <a href="http://www.yicailottery.com/mennns-nike-roshe-run-triangle-gr%C3%B8nn-bl%C3%A5-scarpeb">mennns nike roshe run triangle gr酶nn bl氓</a> <a href="http://www.calebcraw.com/nike-air-max-2019-green-uk-shoeso">nike air max 2019 green uk</a> <a href="http://www.liquidputter.com/nike-flyknit-lunar-3-lilla-mattress-kurpesb">nike flyknit lunar 3 lilla mattress</a>
ifshaildamage http://www.ifshaildamage.com/
lumalender
 lumalender 2019-02-11 14:00回复
#81
<a href="http://www.haceryeni.com/herren-salomon-xt-hornet-gold-orange-obuvd">herren salomon xt hornet gold orange</a> <a href="http://www.klarinetino.com/nike-hyperdunk-2015-low-vert-scarpea">nike hyperdunk 2015 low vert</a> <a href="http://www.pitcrewcooks.com/mujeres-nike-air-presto-todas-naranja-scarpef">mujeres nike air presto todas naranja</a> <a href="http://www.zketchy.com/flyknit-lunar-1-schwarz-and-wei%C3%9F-obuvd">flyknit lunar 1 schwarz and wei脽</a> <a href="http://www.cantleylaw.com/air-jordan-future-premium-glow-weave-rouge-noir-jack-scarpea">air jordan future premium glow weave rouge noir jack</a> <a href="http://www.carikindl.com/kobe-5-varsity-rojo-amarillo-chaussuresg">kobe 5 varsity rojo amarillo</a>
lumalender http://www.lumalender.com/
aldervets
 aldervets 2019-02-09 17:20回复
#80
<a href="http://www.sguerradesign.com/air-jordan-retro-9-womens-green-sky-blue-shoesj">air jordan retro 9 womens green sky blue</a> <a href="http://www.zeneventsja.com/nike-air-max-bl%C3%A5-kvinders-skoi">nike air max bl氓 kvinders</a> <a href="http://www.adharaweb.com/under-armour-curry-one-rosa-blu-scarpel">under armour curry one rosa blu</a> <a href="http://www.jrelselaw.com/womens-nike-cortez-pink-yellow-shoesj">womens nike cortez pink yellow</a> <a href="http://www.intellalegal.com/michael-kors-black-backpack-with-gold-studs-mkh">michael kors black backpack with gold studs</a> <a href="http://www.carmelscoffee.com/nike-free-run-2-kvinners-svart-hvit-obuvi">nike free run 2 kvinners svart hvit</a>
aldervets http://www.aldervets.com/
hamshrd
 hamshrd 2019-02-09 13:50回复
#79
<a href="http://www.albainmaz.com/jordan-4-rosado-toddler-kurpesa">jordan 4 rosado toddler</a> <a href="http://www.seemyvcard.com/nike-roshe-run-floral-tick-sneakerb">nike roshe run floral tick</a> <a href="http://www.joegauntlett.com/nike-roshe-run-nm-white-black-shoesg">nike roshe run nm white black</a> <a href="http://www.rpnailsalon.com/chicago-bears-santa-hat-hats">chicago bears santa hat</a> <a href="http://www.hrubinlaser.com/nike-zoom-pegasus-33-shield-review-sneakerf">nike zoom pegasus 33 shield review</a> <a href="http://www.pruvitallday.com/nike-zoom-structure-20-gul-lyser%C3%B8d-obuvc">nike zoom structure 20 gul lyser酶d</a>
[url=http://www.hamshrd.com/]hamshrd[/url]
stalksdesign
 stalksdesign 2019-02-05 20:53回复
#78
<a href="http://www.jobbstockholm.com/asics-gel-kinsei-5-r%C3%B8d-hvid-sort-desert-obuvc">asics gel kinsei 5 r酶d hvid sort desert</a> <a href="http://www.johnklymshyn.com/nike-air-force-1-triple-blanco-ice-butya">nike air force 1 triple blanco ice</a> <a href="http://www.medicinennet.com/nike-orange-stephone-anthony-name-number-logo-nfl-44-miami-dolphins-t-shirt-nflu">nike orange stephone anthony name number logo nfl 44 miami dolphins t shirt</a> <a href="http://www.nereephotos.com/nike-air-max-90-rose-or-femmes-boots-kurpesc">nike air max 90 rose or femmes boots</a> <a href="http://www.nutraxtractor.com/nike-flyknit-lunar-2-bl%C3%A5-orange-hood-schuhed">nike flyknit lunar 2 bl氓 orange hood</a> <a href="http://www.resqglobal.com/flyknit-lunar-3-svart-and-hvit-trailer-schuheg">flyknit lunar 3 svart and hvit trailer</a>
stalksdesign http://www.stalksdesign.com/
veskopetrov
 veskopetrov 2019-02-05 05:36回复
#77
<a href="http://www.ortzproducts.com/mens-nike-air-force-1-grey-yellow-shoesi">mens nike air force 1 grey yellow</a> <a href="http://www.cooterscamera.com/nike-shox-turbo-21-gr%C3%A5-bl%C3%A5-skoj">nike shox turbo 21 gr氓 bl氓</a> <a href="http://www.marjalfun.com/mennns-nike-free-tr-gr%C3%B8nn-gul-obuvi">mennns nike free tr gr酶nn gul</a> <a href="http://www.alecsblog.com/nike-kd-8-kvinners-hvit-svart-obuvp">nike kd 8 kvinners hvit svart</a> <a href="http://www.troudumonde.com/nike-zoom-pegasus-33-bl%C3%A5-oransje-obuvi">nike zoom pegasus 33 bl氓 oransje</a> <a href="http://www.smilesdrdavid.com/hombres-nike-air-max-tailwind-8-rosado-amarillo-zapatosp">hombres nike air max tailwind 8 rosado amarillo</a>
veskopetrov http://www.veskopetrov.com/
顶部留言底部
 00:00/00:00
我想和你虚度时光 - 花房姑娘(9)
  1. 我想和你虚度时光
  2. 花房姑娘
  3. 恋恋风尘
  4. 我喜爱一切不彻底的事物
  5. 我的心里是满的
  6. Long Way
  7. 给少年的歌
  8. 晴日共剪窗
  9. 天上的月你的脸