Set the output of a function equal to a variable

Posted by ryno on Stack Overflow See other posts from Stack Overflow or by ryno
Published on 2012-07-06T20:51:40Z Indexed on 2012/07/06 21:16 UTC
Read the original article Hit count: 185

Filed under:
|
|

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?

© Stack Overflow or respective owner

Related posts about php

Related posts about css