In my little age with WordPress, I've seen WordPress itself and its friendly plugins are using PHP
serialize() in storing data into db in many cases. But in a recent search I found a serious community support for the
json_encode() over the
- A test that proves
json_encode()is better than
- Reasons why
json_encode()can be used and why not - StackOverflow
And I personally tested an associative array with both of 'em, that shows:
serialize()stores 342 chars
json_encode()stores 285 chars
Why I'm asking this?
I'm on a project while I'm going to store repeating meta fields to a post. Where:
- Data would be basically in English, but sometimes can be Bengali
- Data would be associative array, 3 level deep (I hope I understood levels correctly):
array( 1 => array( 'key'=>'value', 'key2'=>'value' ), 2 => array( 'key'=>'value', 'key2'=>'value' ) )
I've checked the
meta_value field it's a
longtext, that means a length of 4,294,967,295 chars (4GB).
So I need a robust solution into storing things.