processing a binary file?

This is a discussion on processing a binary file? within the alt.comp.lang.php forums, part of the PHP Programming Forums category; If you get the contents of a binary file like with $str = file_get_contents($fname); is there a way that you ...


Go Back   Usenet Forums > PHP Programming Forums > alt.comp.lang.php

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 02-04-2006
Kirk Johansen
 
Posts: n/a
Default processing a binary file?


If you get the contents of a binary file like with
$str = file_get_contents($fname);

is there a way that you can access the elements of $str?
$str may be hundreds of kilobytes and contains binary data and I need
to process each byte of the string and write the processed byte to
another file. Something efficient like [$i]?

Kirk

Reply With Quote
  #2 (permalink)  
Old 02-04-2006
ZeldorBlat
 
Posts: n/a
Default Re: processing a binary file?


Kirk Johansen wrote:
> If you get the contents of a binary file like with
> $str = file_get_contents($fname);
>
> is there a way that you can access the elements of $str?
> $str may be hundreds of kilobytes and contains binary data and I need
> to process each byte of the string and write the processed byte to
> another file. Something efficient like [$i]?
>
> Kirk


You can use strings like arrays: $str{$i} will get you the $i'th
character of the string, indexed from 0. Of course the meaning of a
single character in your string will depend on the data and it's format.

Reply With Quote
  #3 (permalink)  
Old 02-05-2006
Richard Brooks
 
Posts: n/a
Default Re: processing a binary file?

Kirk Johansen wrote:
> If you get the contents of a binary file like with
> $str = file_get_contents($fname);
>
> is there a way that you can access the elements of $str?
> $str may be hundreds of kilobytes and contains binary data and I need
> to process each byte of the string and write the processed byte to
> another file. Something efficient like [$i]?
>
> Kirk
>


Any reason why you wouldn't want to download the whole file and then
examine it in a hex editor ?

Also, you might find the folowing handy if you are thinking of looking
out for text!

<http://www.lookuptables.com/>


Richard.
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 06:33 AM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0