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 ...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
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 |
|
|||
|
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. |
|
|||
|
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. |