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: 1086
/ 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