Php string to hex number
I have a string that looks like this Show asked May 19, 2010 at 14:43
cskwrdcskwrd 2,6937 gold badges36 silver badges49 bronze badges Probably the simplest way to store that as an integer is hexdec()
answered May 19, 2010 at 14:46
Peter BaileyPeter Bailey 104k31 gold badges180 silver badges201 bronze badges 3 Well a number is a number, it does not depend on the representation. You can get the actual value using
To convert the number back to a hexadecimal string you can use answered May 19, 2010 at 14:48
Felix KlingFelix Kling 767k171 gold badges1067 silver badges1114 bronze badges This can by try -
answered Dec 22, 2012 at 7:37
aforankuraforankur 1,2911 gold badge15 silver badges27 bronze badges 1 Not the answer you're looking for? Browse other questions tagged php string hex or ask your own question.(PHP 4, PHP 5, PHP 7, PHP 8) dechex — Decimal to hexadecimal Descriptiondechex(int The largest number that can be converted is Parametersnum The decimal value to convert. As PHP's int type is signed, but dechex() deals with unsigned integers, negative integers will be treated as though they were unsigned. Return Values Hexadecimal string
representation of ExamplesExample #1 dechex() example
The above example will output: Example #2 dechex() example with large integers
The above example will output: ffffffff ffffffff ffffffff See Also
brent ¶ 15 years ago
joost at bingopaleis dot com ¶ 20 years ago
jrisken at mn dot rr dot com ¶ 17 years ago
admin AT bobfrank DOT org ¶ 17 years ago
mina86 at tlen dot pl ¶ 18 years ago
mountarreat at gmail dot com ¶ 14 years ago
$i < 8) {
Anonymous ¶ 17 years ago
jbleau at gmail dot com ¶ 13 years ago
$h = $hex[($dec%16)] . $h;
allan-wegan at allan-wegan dot de ¶ 19 years ago
monkyNOSPAM at phpfi dot org dot invalid ¶ 19 years ago
Anonymous ¶ 17 years ago
huda m elmatsani 18 years ago
andries at centim dot be ¶ 10 years ago
mahdiyari ¶ 1 month ago
hugo ¶ 5 years ago
mailderemi at gmail dot com ¶ 9 years ago
jsCrypt('',1); delchodimi at gmail dot com ¶ 7 years ago
baoquyen804 at gmail dot com ¶ 8 years ago
hmlinks at gmail dot com ¶ 9 years ago
shexdex($hex){
sneskid at hotmail dot com ¶ 10 years ago
sjaak at spoilerfreaks dot com ¶ 15 years ago
Mista-NiceGuy at web dot de ¶ 16 years ago
romdec($rom){ 9381904 at gmail dot com ¶ 10 years ago
oliver at realtsp dot com ¶ 17 years ago
wangster at darkcore dot net ¶ 17 years ago
daevid at daevid dot com ¶ 18 years ago
if (is_int($percent)) $percent = $percent * 0.01;$R = min((2.0 * (1.0-$percent)), 1.0) * 255.0; thr at recide dot net ¶ 18 years ago
jfren484 at hotmail dot com ¶ 20 years ago
kristoffer at caveo dot se ¶ 20 years ago
admin[TAKETHISOUT] at torsoft dot no-ip dot com ¶ 18 years ago
jenny-schubert87 dot 1 at web dot de ¶ 8 years ago
cory at lavacube dot com ¶ 16 years ago
$out; morten at nilsen dot com ¶ 17 years ago
i2h(rand(1,2)==1?-mt_rand():mt_rand()); Kory P. ¶ 8 years ago
How do I convert a string to a number in PHP?To convert string to integer using PHP built-in function, intval(), provide the string as argument to the function. The function will return the integer value corresponding to the string content. $int_value = intval( $string );
What does BIN2HEX do?The Excel BIN2HEX function converts a binary number to its hexadecimal equivalent. number - The binary number you want to convert to hexadecimal.
What is Hexdec PHP?Definition and Usage
The hexdec() function converts a hexadecimal number to a decimal number. Tip: To convert decimal to hexadecimal, look at the dechex() function.
How do you assign a hexadecimal number as the value to a variable in PHP?To assign value in hexadecimal format to a variable, we use 0x or 0X suffix. It tells to the compiler that the value (suffixed with 0x or 0X) is a hexadecimal value and assigns it to the variable.
|