You can use json format. Checkout json_encode() function. With binary data problem is little more complicated but it can be also solved. You can convert them to base64 format with base64_encode. Then everything will be stored in clear ASCII without any gibberish.
How to store associated array with binary data for editing in notepad?
Question
I have an array and it looks like
$a=array('HEX'=>Chr(0).Chr(1).Chr(2),'b'=>123,'c'.......);
I need to store it in text file, open in text editor and edit it.
$fwp = fopen ('edit.txt', "wb");
FWrite($fwp,var_export($a,true));
FClose ($fwp);
I see that the hex data is stored as 'HEX' => '' . "\0" . [][] '' and it seems to be lost after load-save in text editor.
So, how to store it binary-safe in php?
Solution
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow