user2978324
user2978324

Reputation: 13

How to convert a variable to hex

I have a variable $foreground = 'FF03FF' and I want to convert that variable to $foreground = 0xFF03FF. How do i can convert it using php? Please help me.

Upvotes: 0

Views: 285

Answers (1)

UltraInstinct
UltraInstinct

Reputation: 44444

You can use hexdec(..) function

echo hexdec('FF03FF');

Output: 16712703 (in hex: 0xFF03FF)

Upvotes: 1

Related Questions