Reputation: 7438
I got the following color -16777216
and I want to convert it to a alpha-hex code like this 00FFBBCC
in PHP. I also want to be able to do the reverse. I really don't know where to start and my friend Google has no answer for me.
Any one can help please ?
Thank you.
Upvotes: -1
Views: 704
Reputation: 131
What about using dechex()?
echo dechex(-16777216);
It outputs ff000000
If you want uppercase letters, simply use strtoupper():
echo strtoupper(dechex(-16777216)); //FF000000
Edit: to do the reverse, use hexdec() instead of dechex()
Upvotes: 1