Re: concat 2 binary files?
- From: Janwillem Borleffs <jw@xxxxxxxxxxxxx>
- Date: Mon, 20 Jun 2005 12:18:30 +0200
herc777@xxxxxxxxxxx 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
.
- Follow-Ups:
- Re: concat 2 binary files?
- From: herc777
- Re: concat 2 binary files?
- References:
- concat 2 binary files?
- From: herc777
- concat 2 binary files?
- Prev by Date: Re: PHP saying I have an undefined variable?
- Next by Date: Re: concat 2 binary files?
- Previous by thread: concat 2 binary files?
- Next by thread: Re: concat 2 binary files?
- Index(es):