Sat, July 24, 2021
 
https://devcodepro.comdevcodepro
X
Home · Latest · Trends
8

Smarty Random Color

<?php
/*
 * Smarty plugin
 * -------------------------------------------------------------
 * File:     function.randomcolor.php
 * Type:     function
 * Name:     randomcolor
 * Purpose:  outputs random color
 * Usage:    {foreach...}<div style="background:{randomcolor};height:40px;width:40px;">randomcolor</div>{/foreach}
 * -------------------------------------------------------------
 */
function smarty_function_randomcolor($params, Smarty_Internal_Template $template)
{
    $colors = ['#ccdb38','#a676b8','#fe7e17','#EC3A56','#1DBFFF','#02d3a4','#bc02d3','#025fd3','#297fa0','#539239','#fe9717','#a0a0a0','#b666bf','#dcdc08'];
    $result = array_rand($colors);
    return $colors[$result];
}
?>
rated 8 times (8) (0)
comments: 0 / hits: 1368  / 2 years ago, sun, jun 16, 19, 01:53:29
More From » PHP
 

Comments

There are no comments for this Snippet yet
Only authorized users can post. Please sign in first, or register a free account
 
Share
Posted
jimmy
Member since Dec 15, 2016
Total Code Snippets: 16
Total Comments: 2
Location: n/a
jimmy snippets
5 years ago, mon, dec 5, 16, 1:47:20
comments: 1 / hits: 4291
PHP
5 years ago, mon, jan 9, 17, 2:50:09
comments: 1 / hits: 23696
PHP
5 years ago, mon, jan 16, 17, 2:18:41
comments: 1 / hits: 2752
PHP
5 years ago, sat, jan 21, 17, 5:41:42
comments: 0 / hits: 3726
PHP
5 years ago, fri, feb 10, 17, 12:02:07
comments: 1 / hits: 2701
PHP
5 years ago, fri, feb 10, 17, 12:15:34
comments: 0 / hits: 2053
PHP
5 years ago, tue, feb 28, 17, 9:40:06
comments: 0 / hits: 1924
PHP
4 years ago, sun, mar 5, 17, 1:51:18
comments: 1 / hits: 4819
PHP
4 years ago, thu, mar 16, 17, 5:51:45
comments: 1 / hits: 2028
PHP