How do I write data to a binary file using php, and then read it back?
Thanks.
Better question, how do you plan on creating the binary data to be written to the file?
Thats probably the question I should have asked. 🙂 What I'm wanting to do is store a text string as binary, and then be able to read it back.
use fwrite() and fread(), they are Binary-safe.
http://www.php.net/manual/function.fwrite.php
Perhaps you could describe what you mean by "store a text string as binary". It's not clear to me what you are trying to accomplish, or what need this is meeting...
<G> CHR(); eh?
Michael
chr()? Tried using it like this: chr(0x49) (for example) and it simply writes out the ASCII equivalent.
Well take the MySQL replication logfile. It has to store the same info as a mysqldump of all the updates/inserts etc. However, it stores this not as plain text, but as a binary log.
Sure, but there's presumably lots of binary data there. Where I got lost was when you explained, "What I'm wanting to do is store a text string as binary..." :-)