|
Posted by Janwillem Borleffs on 06/20/05 13:18
herc777@hotmail.com wrote:
> I want to manipulate binary files.
>
> this was just a test to concatinate 2 text files but it said
> file_put_contents was undefined. the second parameter is suppoed to be
> 'mixed data', no idea what that is.
>
The file_put_contents() function is only supported on PHP v >= 5; the
indication mixed data means that it can be anything from a scalar to an
array.
> But this was just a test anyway since file_get_contents uses strings,
> can someone just give me the code to concat 2 binary files? I'll be
> manipulating the files before I concatinate them, so putting the data
> into 2 arrays of bytes 1st would be best.
>
An alternative for file_put_contents on PHP 4.x would be to apply fopen
with ``wb'' as the switch and fputs for writing:
$fp = fopen("somenewfile", "wb");
fputs($fp, $data_1 . $data_2);
fclose($fp);
Since file_get_contents() is binary safe, the binary data will be
untouched and the merge successful, provided that the binary data
actually can be merged this way...
JW
Navigation:
[Reply to this message]
|