I have an array:
Array
(
[red] => 252
[green] => 168
[blue] => 166
[alpha] => 0
)
It’s an output of function imagecolorsforindex.
How can I get a HTML code from these elements? For example: #99CCFF
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Strictly speaking you can’t, since alpha is not supported. But since the alpha is 0, we can assume that it won’t matter. As such, pass each value into
sprintf()with a format specifier of%02xfor each element.