David19801
David19801

Reputation: 11448

Decimal to hex string

I have a decimal value of a utf-32 character:

$a=21644;

How can I convert this using php to a string of the hex? '548c'

Here is the page for the codes I am using: http://www.fileformat.info/info/unicode/char/548c/index.htm

Upvotes: 0

Views: 4333

Answers (2)

fivedigit
fivedigit

Reputation: 18682

You'll want to use dechex:

$hex = dechex($decimal);

Read more here

Upvotes: 2

TimWolla
TimWolla

Reputation: 32701

dechex is what you need here:

php > echo dechex(21644);
548c

Upvotes: 3

Related Questions