Set the output of a function equal to a variable
- by ryno
How would i set the output of a custom php function to a variable?
The function is:
function getRandomColor1() {
global $cols;
$num_cols = count($cols);
$rand = array_rand($cols);
$rand_col = $cols[$rand];
echo $rand_col;
unset($cols[$rand]);
}
How would i set getRandomColor1 equal to $RandomColor1?
I need it to be a variable so I can use it in css like:
#boxone1 {
height: 150px;
width: 150px;
background: <?=$RandomColor1?>;
float: left;
}
If its not possible to set it as a variable, how else could i put the output of the function into css?