[thelist] Binary file manipulation in PHP
Jeffrey Barke
jeffrey.barke at themechanism.com
Wed Feb 13 13:33:59 CST 2008
Rick,
I only worked with binary files once and it was experiment, but I
believe you need the pack() and unpack() functions:
<http://us3.php.net/manual/en/function.pack.php>
<http://w-shadow.com/blog/2006/10/17/processing-binary-files-in-php/>
Jeffrey
On Feb 13, 2008, at 11:26 AM, Rick den Haan wrote:
> David Menzel wrote:
>> While I havnt done to much with binary files in php, i believe you
>> need
>> the file_get_contents function.
>> http://us.php.net/manual/en/function.file-get-contents.php
>>
>> Also, you could try setting the binary flag on fread if you havnt
>> already.
>>
>> Good luck
>
> Thanks, but getting the contents of the file is no problem. For
> example, to
> get the version number (first 2 bytes in the file), I use:
>
> $rHandler = fopen($sFilename, 'rb');
> $binVersion = fread($rHandler, 2);
>
> This moves the pointer, so to get the file type (the next 8 bytes),
> I can
> then do
>
> $binType = fread($rHandler, 8);
>
> to get bytes 3 through 10.
>
> The trick is, what do I need to do to $binVersion and $binType to get
> something human-readable?
>
> Thanks,
> Rick.
>
> --
>
> * * Please support the community that supports you. * *
> http://evolt.org/help_support_evolt/
>
> For unsubscribe and other options, including the Tip Harvester
> and archives of thelist go to: http://lists.evolt.org
> Workers of the Web, evolt !
--
Cheers.
Jeffrey Barke
jeffrey.barke at theMechanism.com
Lead Developer, US
theMechanism - New York City
440 9th Avenue, 8th Floor
New York, NY 10001-1631
t: +1 212.404.3150
c: +1 917.941.1232
f: +1 212.404.3228
http://www.theMechanism.com
Subscribe to theMechcast, our monthly Podcast:
http://feeds.feedburner.com/theMechcast
theMechanism - London
3rd Floor
405 The Strand
London E14 9FW
United Kingdom
t: +44 (0)20 7240 4964
f: +44 (0)20 7240 2262
--
The information contained in this Electronic mail message is attorney
privileged and confidential information intended only for the use of
the individual or entity named above. Such information also is
intended to be privileged, confidential, and exempt from disclosure
under applicable law. If the reader of this message is not the
intended recipient or the employee or agent responsible to deliver it
to the intended recipient, you are hereby notified that any
dissemination, distribution, or copying of this communication is
strictly prohibited. If you have received this communication in error,
please notify us immediately by telephone.
Blah, blah, blah...
--
More information about the thelist
mailing list