Preferred method to store PHP arrays (json_encode vs serialize)

前端 未结 20 2177
孤独总比滥情好
孤独总比滥情好 2020-11-22 05:55

I need to store a multi-dimensional associative array of data in a flat file for caching purposes. I might occasionally come across the need to convert it to JSON for use in

20条回答
  •  暗喜
    暗喜 (楼主)
    2020-11-22 06:33

    I've written a blogpost about this subject: "Cache a large array: JSON, serialize or var_export?". In this post it is shown that serialize is the best choice for small to large sized arrays. For very large arrays (> 70MB) JSON is the better choice.

提交回复
热议问题