Answer the question
In order to leave comments, you need to log in
Will there be problems when storing an array as base64 + serialize?
Problem in the following:
There is a multidimensional associative array containing a lot of different data, including line breaks and html fragments.
When saving an array to a file in the form of serialize($array), there was a problem:
when downloading a file from the server (freebsd) to the local computer (win8) - unserialize gives false when reading, while loading the same (just downloaded) file back Everything works fine on the server.
The only working option is to encode the result of serialize($array) in base64, then everything works.
So the question is, is it normal practice to use base64_encode( serialize($array) ) or could there be problems? (for example, with decoding speed, etc.)
The file size after base64 + serialize is 20-50 KB.
Answer the question
In order to leave comments, you need to log in
Apparently, there are problems in the area of line wrapping - \n and \r\n (different lengths).
You are probably downloading from the server either via copy/paste or via ftp in "text" mode, or I don't know how, but your video either changes \n to \r\n or vice versa. Either you are reading/writing the file in non-binary mode.
If you deal with the download (make it binary), then the problem will disappear.
At 20-50 KB, most likely there will be no problems, the algorithm is "streaming", that is, the amount of memory and calculations does not depend on the size of the data.
Alternatively, try looking in the direction of json_encode / json_decode.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question