reading binary code of a file...in PHP

Posted by Val on Stack Overflow See other posts from Stack Overflow or by Val
Published on 2010-02-04T14:52:48Z Indexed on 2010/04/22 12:23 UTC
Read the original article Hit count: 210

Filed under:
|

How can I read the binary code(to get the 1s and 0s) of a file.

$filename = "something.mp3";
$handle = fopen($filename, "rb");
$contents = fread($handle, filesize($filename));
fclose($handle);

I tried this but it shows some strange characters... i presume that this is the formated binary...? I was hoping to get the 1's and 0's instead....

also i am not looking only .mp3 files it could be anything .e.g: .txt , .doc , .mp4, .php .jpg,.png etc....

Thanks

© Stack Overflow or respective owner

Related posts about binary

Related posts about php