Jump to content

View more

Image of the Day

The night is still, but the invasion brings chaos. #screenshotsaturday #hanako #indiegame #gameart #ue4 #samurai https://t.co/cgILXuokoS
IOTD | Top Screenshots

The latest, straight to your Inbox.

Subscribe to GameDev.net Direct to receive the latest updates and exclusive content.


Sign up now

[web] unpack: Binary string to hex string (PHP)

4: Adsense

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.


  • You cannot reply to this topic
2 replies to this topic

#1 BeanDog   Members   

1065
Like
0Likes
Like

Posted 18 November 2005 - 04:52 AM

I'm trying to use the unpack function in PHP to convert a text or binary string to its hexadecimal representation (e.g. 'hello' -> '68656c6c6f')
function _hexstring($bin)
{
	list(,$ret) = unpack('h1', $bin);
	return($ret);
}
I'm missing something fundamental here. It returns a blank string. Anybody have an idea? ~BenDilts( void );

#2 konForce   Members   

592
Like
0Likes
Like

Posted 18 November 2005 - 07:33 AM

Try:


function _hexstring($bin)
{
list(,$ret) = unpack('H'.strlen($bin)*2, $bin);
return($ret);
}



#3 BeanDog   Members   

1065
Like
0Likes
Like

Posted 18 November 2005 - 07:54 AM


function _hexstring($bin)
{
list(,$ret) = unpack('h*1', $bin);
return($ret);
}

Solved.

Thanks, you pointed me in the right direction!



~BenDilts( void );




Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.