Q:

Editing file's hex at specific point in PHP?

What I'm trying to accomplish:
I have two base files on my server that are edited/copied as needed based on user input. I'm hoping to do most of the work with the user input in javascript and the file editing in PHP, as I'm better with javascript. What I will need to do is edit the files at specific points and change the hex values based on the lengths of certain user-inputted strings. 
I've done as much as I could without asking for help, but now I definitely need it. 
The way one of the files is structured is: three null hex values, then a hex value equivalent to the length of a setting string, the setting string, three more null hex values, a hex value equivalent to the length of the setting's value string, and finally the value string. An example would be:
06 76 6F 6C 75 6D 65 00 00 00 02 37 38
06 is the length of the "volume" string,
76 6F 6C 75 6D 65 is the "volume" string,
02 is the length of the value string for volume, "78"
37 38 is the setting value, "78"
I can covert the user input to hex myself, but I don't know how to write to file in hex, or open it in hex, or go to the place I need to...
Also, for some reason, 000webhost won't let me upload txt files or the files I need to use, so is there a way to use zip files with php?
One last thing, how do I transfer variables between javascript and php without writing them to an html element?

A:

You don't need to do anything special to write in hex. Just store your value and output it, php is binary safe. (Don't store the string "76", store a character with the value 76.)
Then use the various file command to read and write your file like @myeviltacos said.
And you do (more or less) need to put your variable in html elements to transfer them.
You have four options:
A form with hidden elements, then submit it.
Create a url with the variables in the url and go to it.
Use ajax and do the same as the previous two options.
And finally you can use jQuery and let it do it for you automatically. Use $.ajax() and set the data property to your variables.

