Scenario : i have an extension which requires an external binary (data) file. Since the extension has to be cross platform, the data file has to be built on the target platform to ensure that there are no endian issues. Therefore, i transform the file into a csv file of byte values, hoping to use Pack at the final stage of the build process to create a platform-endian file.
The Problem Pack is written "vararg" style, which works great for a small set of values, but is a pain for larger sets of data. i know its possible to loop through my data and do a per-byte conversion, but my file is currently near 90K. Suggestion: Allow for an array as the second parameter. That way all i need to do is : $new_file = fopen($platform_file, "wb"); $lines = file($big_binary_file); foreach ($lines as $line) { $array_of_bytes_as_string = split(",", $line); $bin_string = pack("C*", $array_of_bytes_as_string); fwrite($new_file, $bin_string); } fclose($new_file); In Case You're Wondering: Why am i not doing this via C ? it is quite possible for parts of the total data set to change between releases of the extension. the file i want to convert is fairly static, but there are other data files which the extension user may customize, or that may need to be corrected. in that case, a simple PHP script can be run to create the binary file. No compiler or PHP build environment is necessary, and there is no need to wait for a new release of the extension. l0t3k -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php