0

I'm translating some Coldfusion code to PHP, and am trying to figure out how to do the "binaryencode" function. This is my code -- it takes a long string of hex characters and outputs them as a GIF image.

<cfset GIF = "CCFFCC.....">
<cfset output = binarydecode(GIF,'Hex')>
<cfcontent type="image/gif" reset="yes" variable="#output#">

I have looked at the raw output of binarydecode(), and at all of the binary, hex, and image functions in PHP, but can't find the right combination to get the same output.

Suggestions?

ray.gurganus
  • 119
  • 1
  • 2
  • 10
  • possible duplicate of - http://stackoverflow.com/questions/6382738/convert-string-to-binary-then-back-again-using-php ? If not that then this - http://www.hotscripts.com/forums/php/47235-solved-how-transfer-string-binary.html ? – Matt Busche Feb 19 '13 at 04:43

1 Answers1

0

Found an answer. Not really an explanation as to what's happening, but at least something that does the job. On this page: http://www.drupaluser.org/php_manual/function.pack.html

I found this, which returns the comparable results to what binarydecode() does.

$output = pack("H".strlen($GIF),$GIF);
ray.gurganus
  • 119
  • 1
  • 2
  • 10