Re: Writing Binary

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



# likelink@xxxxxxxxxxxxxx / 2007-01-01 15:15:07 -0500:
> Hello Everyone,
>    I'm trying to write a PHP script that opens a binary file, reads the 
> binary in chunks, checks those chunks for a certain binary string, and 
> then if the string is found, it replaces the string with another binary 
> string.  The script should then a copy of the file, including the 
> changed bits.  But for some reason, the script is not replacing the 
> binary string.
> 
> Here's the source code:
> 
> <?php
> 
> $in = fopen("C:\NeighborhoodManager.package", "rb");
> $out = fopen("C:\NeighborhoodManager2.package", "w");
> $count = 0;
> 
> while (!feof($in)) {
>  $count++;
>  $buffer = fread($in,50000);
>  if 
> (eregi("0101001101110100011100100110000101101110011001110110010101110100011011110111011101101110",$buffer))

Binary mode ("rb") doesn't mean PHP will translate each bit of the data
into a 7-bit (or longer) textual representation.

http://www.php.net/manual/en/function.pack.php
http://www.php.net/manual/en/function.unpack.php

-- 
How many Vietnam vets does it take to screw in a light bulb?
You don't know, man.  You don't KNOW.
Cause you weren't THERE.             http://bash.org/?255991

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux