note 80263 added to ref.strings
| From: | geek dot de at gmail dot com | Date: | Mon, 07 Jan 2008 11:18:40 +0000 |
| Subject: | note 80263 added to ref.strings | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-134911@lists.php.net to get a copy of this message | ||
This took me quite some time to figure out and it is so obvious. So, I hope it helps someone out
there like it would have helped me if I would have found it on this page:
I wanted to read a binary file and write it out with some modified bytes with their hex values. The
easiest way I could come up with was the following:
read the file line by line, e.g. 400 bytes and then chuck it into an array with e.g.
<?php
$handle = @fopen("/path/to/file.bin", "r");
if ($handle) {
while (!feof($handle)) {
$buffer[] = fgets($handle, 400);
}
fclose($handle);
$buffer[0][0] = chr(hexdec("FF")); // set the first byte to 0xFF
}
// write out the file from the array ...
?>
One could write a function for that, so that One can write a string of bytes. Don't have time
for this now but you should get the idea.
----
Server IP: 69.147.83.197
Probable Submitter: 219.88.93.2
----
Manual Page -- http://www.php.net/manual/en/ref.strings.php
Edit -- https://master.php.net/note/edit/80263
Del: integrated -- https://master.php.net/note/delete/80263/integrated
Del: useless -- https://master.php.net/note/delete/80263/useless
Del: bad code -- https://master.php.net/note/delete/80263/bad+code
Del: spam -- https://master.php.net/note/delete/80263/spam
Del: non-english -- https://master.php.net/note/delete/80263/non-english
Del: in docs -- https://master.php.net/note/delete/80263/in+docs
Del: other reasons-- https://master.php.net/note/delete/80263
Reject -- https://master.php.net/note/reject/80263
Search -- https://master.php.net/manage/user-notes.php