好!欢迎访问迷津渡口 现在时间是: 天气 °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获取随机颜色
   支持一下
挤眼 亲亲 咆哮 开心 想想 可怜 糗大了 委屈 哈哈 小声点 右哼哼 左哼哼 疑问 坏笑 赚钱啦 悲伤 耍酷 勾引 厉害 握手 耶 嘻嘻 害羞 鼓掌 馋嘴 抓狂 抱抱 围观 威武 给力
 点赞
 签到
 表情
 图片
 代码
提交评论

清空信息
关闭评论
malatyabolge
 malatyabolge 37 分钟前回复
#176
<a href="http://www.mlslawfirm.com/nike-air-max-270-army-gr%C3%B8n-sort-hvid-orange-skoh">nike air max 270 army gr酶n sort hvid orange</a> <a href="http://www.alinakrocheva.com/nike-air-max-95-ultra-essential-blu-cross-scarpei">nike air max 95 ultra essential blu cross</a> <a href="http://www.sebdmnfv.com/maschio-mizuno-basara-001-as-wid-tpu-rosso-scarpej">maschio mizuno basara 001 as wid tpu rosso</a> <a href="http://www.rgmclaims.com/los-angeles-clippers-chris-paul-jersey-nflh">los angeles clippers chris paul jersey</a> <a href="http://www.karmicfix.com/coach-boxed-universal-pocket-phone-wallet-coachh">coach boxed universal pocket phone wallet</a> <a href="http://www.marbacapital.com/nike-blazer-cachi-verde-scarpei">nike blazer cachi verde</a>
malatyabolge http://www.malatyabolge.com/
playunreal
 playunreal 约 1 小时前回复
#175
<a href="http://www.teddevans.com/nike-dunk-high-hellboy-rot-schuhej">nike dunk high hellboy rot</a> <a href="http://www.cateycontrols.com/nike-sb-stefan-janoski-max-trainers-in-grau-schuhei">nike sb stefan janoski max trainers in grau</a> <a href="http://www.prodomfactory.com/air-jordan-cp3-svart-r%C3%B8d-obuvj">air jordan cp3 svart r酶d</a> <a href="http://www.tonyaespinoza.com/nike-flyknit-air-vapormax-2018-viola-bianca-scarpel">nike flyknit air vapormax 2018 viola bianca</a> <a href="http://www.nemagrp.com/femmes-marine-bleu-converse-chaussures-chaussuresh">femmes marine bleu converse chaussures</a> <a href="http://www.viajesclic.com/tutti-bianca-pelle-nike-shox-scarpeh">tutti bianca pelle nike shox</a>
playunreal http://www.playunreal.com/
mcguber
 mcguber 约 12 小时前回复
#174
<a href="http://www.smfamilylaw.com/philadelphia-phillies-new-era-mlb-batting-practice-prolight-39thirty-cap-hatk">philadelphia phillies new era mlb batting practice prolight 39thirty cap</a> <a href="http://www.frigoarreda.com/m%C3%A6nd-nike-sock-dart-sp-fragm%C3%A6ndt-dark-bl%C3%A5-skoj">m忙nd nike sock dart sp fragm忙ndt dark bl氓</a> <a href="http://www.veripc.com/polo-shirt-white-and-blue-poloh">polo shirt white and blue</a> <a href="http://www.chrisglahn.com/womens-navy-blue-converse-shoes-shoesi">womens navy blue converse shoes</a> <a href="http://www.itsjustpeople.com/nike-air-max-90-essential-bianca-rosa-foil-nero-scarpej">nike air max 90 essential bianca rosa foil nero</a> <a href="http://www.motorzgirl.com/adidas-originals-wei%C3%9F-gr%C3%BCn-stan-smith-turnschuhe-schuhej">adidas originals wei脽 gr眉n stan smith turnschuhe</a>
mcguber http://www.mcguber.com/
ilankocaeli
 ilankocaeli 约 16 小时前回复
#173
<a href="http://www.dowsadvocate.com/ray-ban-rb4105-price-sunglassesh">ray ban rb4105 price</a> <a href="http://www.laflammesinc.com/nike-air-max-tn-vert-chaussuresl">nike air max tn vert</a> <a href="http://www.thisisitnyc.com/adidas-originals-blanc-stan-smith-trainers-chaussuresl">adidas originals blanc stan smith trainers</a> <a href="http://www.tuurulz.com/nike-air-max-2015-dam%C3%A4nner-lila-blau-schuhej">nike air max 2015 dam盲nner lila blau</a> <a href="http://www.todotecnicos.com/alle-star-converse-low-wei%C3%9F-schuhei">alle star converse low wei脽</a> <a href="http://www.xaviersarrate.com/nike-huarache-ultra-oransje-s%C3%B8lv-obuvj">nike huarache ultra oransje s酶lv</a>
ilankocaeli http://www.ilankocaeli.com/
emcetolerie
 emcetolerie 2019-04-18 07:47回复
#172
<a href="http://www.romoautocare.com/nike-kd-trey-5-silver-blue-shoesj">nike kd trey 5 silver blue</a> <a href="http://www.industrialegy.com/michael-kors-fulton-large-shoulder-bag-navy-nz-mkh">michael kors fulton large shoulder bag navy nz</a> <a href="http://www.bewustvitaal.com/nike-free-run-3-kvinners-s%C3%B8lv-r%C3%B8d-obuvi">nike free run 3 kvinners s酶lv r酶d</a> <a href="http://www.flushandhunt.com/nike-air-max-97-bianca-gituttio-scarpej">nike air max 97 bianca gituttio</a> <a href="http://www.kendalfewster.com/mens-nike-zoom-pegasus-33-blue-yellow-shoesh">mens nike zoom pegasus 33 blue yellow</a> <a href="http://www.gisusalon.com/hombres-nike-free-run-2-rosado-negro-zapatosp">hombres nike free run 2 rosado negro</a>
emcetolerie http://www.emcetolerie.com/
onlinewithgpc
 onlinewithgpc 2019-04-17 23:47回复
#171
<a href="http://www.hypemyplace.com/adidas-tubular-runner-weave-nero-scarpej">adidas tubular runner weave nero</a> <a href="http://www.fajrawy.com/lebron-james-rot-nike-schuhe-schuhei">lebron james rot nike schuhe</a> <a href="http://www.laziophoto.com/kvinder-air-jordan-retro-6-hvid-lyser%C3%B8d-blomst-skoh">kvinder air jordan retro 6 hvid lyser酶d blomst</a> <a href="http://www.thenaturalab.com/kevin-durant-warriors-home-jersey-nfli">kevin durant warriors home jersey</a> <a href="http://www.kurtweideman.com/nike-roshe-run-mennns-svart-and-hvit-obuvk">nike roshe run mennns svart and hvit</a> <a href="http://www.julesmatton.com/signature-coach-backpack-coachh">signature coach backpack</a>
onlinewithgpc http://www.onlinewithgpc.com/
ihmrutland
 ihmrutland 2019-04-17 02:35回复
#170
<a href="http://www.txmed.net/femmes-nike-free-run-2-or-blanc-scarpee">femmes nike free run 2 or blanc</a> <a href="http://www.ukpubs.net/nike-kobe-11-sko-for-salg-butye">nike kobe 11 sko for salg</a> <a href="http://www.uniquewebsitedesign.net/nike-air-max-thea-svart-hvit-logo-butyf">nike air max thea svart hvit logo</a> <a href="http://www.unratedperez.net/nike-kobe-7-elite-wei%C3%9F-schuhea">nike kobe 7 elite wei脽</a> <a href="http://www.urbanintelligence.net/nike-air-max-tn-i-herre-sko-yarn-sort-orange-oil-chaussuresa">nike air max tn i herre sko yarn sort orange oil</a> <a href="http://www.utsweb.net/hombres-nike-shox-turbo-21-rosado-blanco-obuva">hombres nike shox turbo 21 rosado blanco</a>
ihmrutland http://www.ihmrutland.net/
lovemescort
 lovemescort 2019-04-16 23:56回复
#169
<a href="http://www.npmgreenpros.com/air-jordan-retro-6-white-pink-shoesi">air jordan retro 6 white pink</a> <a href="http://www.dosenotomotif.com/femminile-mizuno-wave-prophecy-5-nero-jade-36-41-scarpej">femminile mizuno wave prophecy 5 nero jade 36 41</a> <a href="http://www.kuetahyalilar.com/nike-tiempo-legacy-vi-turf-rot-silber-gelb-schuhej">nike tiempo legacy vi turf rot silber gelb</a> <a href="http://www.seoaddress.com/detroit-lions-47-nfl-overrun-mvp-cap-hath">detroit lions 47 nfl overrun mvp cap</a> <a href="http://www.drpfanstiel.com/hommes-nike-air-max-bw-blanc-bleu-noir-chaussuresh">hommes nike air max bw blanc bleu noir</a> <a href="http://www.ericmichaelpr.com/nike-dunk-sky-hi-wei%C3%9F-snakeskin-schuheh">nike dunk sky hi wei脽 snakeskin</a>
lovemescort http://www.lovemescort.com/
dmvantalya
 dmvantalya 2019-04-16 23:41回复
#168
<a href="http://www.goodmedusa.com/roshe-run-noir-trainers-chaussuresj">roshe run noir trainers</a> <a href="http://www.murskacorp.com/herren-nike-hyperdunk-low-2017-gelb-schuhek">herren nike hyperdunk low 2017 gelb</a> <a href="http://www.prajansim.com/boston-bruins-military-jersey-nflh">boston bruins military jersey</a> <a href="http://www.pokersurga.com/jordan-12-retro-gr%C3%B8nn-obuvi">jordan 12 retro gr酶nn</a> <a href="http://www.arkmmj.com/for-sale-nike-roshe-men-wool-skin-blue-yellow-shoesj">for sale nike roshe men wool skin blue yellow</a> <a href="http://www.butterbroad.com/black-leather-converse-prices-shoesl">black leather converse prices</a>
dmvantalya http://www.dmvantalya.com/
amsinconline
 amsinconline 2019-04-15 00:03回复
#167
<a href="http://www.yogafriendly.com/air-jordan-retro-11-hvit-gull-bl%C3%A5-svart-obuvj">air jordan retro 11 hvit gull bl氓 svart</a> <a href="http://www.btvspassion.com/adidas-tubular-radial-bianca-maschio-scarpel">adidas tubular radial bianca maschio</a> <a href="http://www.trusejenta.com/asics-gel-lyte-3-noir-gris-chaussuresh">asics gel lyte 3 noir gris</a> <a href="http://www.chatgroupies.com/nike-rosso-air-max-1-scarpeh">nike rosso air max 1</a> <a href="http://www.tamarindoyam.com/denver-nuggets-jersey-rainbow-nfli">denver nuggets jersey rainbow</a> <a href="http://www.tinaandcoco.com/mujeres-nike-air-max-360-rojo-zapatosh">mujeres nike air max 360 rojo</a>
[url=http://www.amsinconline.com/]amsinconline[/url]
顶部留言底部
 00:00/00:00
我想和你虚度时光 - 花房姑娘(9)
  1. 我想和你虚度时光
  2. 花房姑娘
  3. 恋恋风尘
  4. 我喜爱一切不彻底的事物
  5. 我的心里是满的
  6. Long Way
  7. 给少年的歌
  8. 晴日共剪窗
  9. 天上的月你的脸