Ive got a PHP script which needs to accept a binary file in HEX, and write it to disc, is there an easy and quick process for converting HEX to a byte and then writing it to a file?
The file is passed through to the PHP script through $_POST['fileContents'], and looks like:-
So I suppose first thing I need to do is split the string into individual bytes and then convert each hex number to its binary and then write that to disc, but my attached code isnt the quickest in the world, is there a way I can speed it up?
$hexArray = explode("-", $_POST['fileContent']);
$write2Disc = ""
foreach ($hexArray as $hexElement)
$write2Disc = $write2Disc . chr(hexdec($hexElement));
$myFile = "testFile.jpg";
$fh = fopen($myFile, 'a');