I tried to save the array information to the database.
serialize
And
json_encode
,
serialize
Than
json_encode
The string length of the conversion is less than 1/3, but want to ask
PHP
There's nothing else.
functionOr
Methodcan be converted.
less-length strings?
Reply content:
Because to save the array information to the database, I tried to use serialize
and json_encode
, serialize
json_encode
1/3 less than the conversion string length, but there is PHP
no other function or method to ask Can I convert a string of less length ?
No need, Json_encode is actually very good, especially considering that the data may be called directly by the front end. If you have enough database space to buy a hard disk, this is the best advice.
The more you compress, the more computationally you need, the more hassle you'll get when you decompress, and the less space-saving performance you'll never get.
You can search your own string compression algorithms, such as http://www.jb51.net/article/46144.htm
Typically, the CPU time is much more expensive than disk space, except for special requirements, so there is no need to waste CPU time for disk space.
Compressing and decompressing strings is time-consuming and not worth it.
The main thing is to look at the requirements, your string compression is used to implement what content, if it is to communicate with other parts, then JSON is a better way to implement. If it is for storage, then forget it.
Implode (Separator,array)
Messagepack is an efficient binary serialization format. It allows you to exchange data between languages like JSON. But it's faster and smaller than JSON.