Reply to Re: concat 2 binary files?

Your name:

Reply:


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

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация