Re: ill sprintf() behavior w/ HEX type

From: Date: Thu, 21 Nov 2002 08:03:57 +0000
Subject: Re: ill sprintf() behavior w/ HEX type
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-125384@lists.php.net to get a copy of this message
On Thursday 21 November 2002 15:51, Chris Wesley wrote: > Using PHP/4.2.2 & Apache/1.3.26 on Linux 2.4.17 > > I'm trying to format a HEX value into an 8-byte string, that is > zero-padded to the left, using sprintf(). Simple enough. > > $sprintf( "%08x", "fa23d" ); > This should return "000fa23d". But it returns "00000000". That's because it's expecting a _decimal_ and will automatically convert it to hex for you. Try: echo $sprintf( "%08x", "1024573" ); -- Jason Wong -> Gremlins Associates -> www.gremlins.biz Open Source Software Systems Integrators * Web Design & Hosting * Internet & Intranet Applications Development * /* "All Bibles are man-made." -- Thomas Edison */

« previous php.general (#125384) next »