Drupal Answers is a question and answer site for Drupal developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have an use-case where a large associative array is getting generated while saving a node. The array is for a specific content type. I want to save the array along with the node.

While saving all the values of an array to different fields is not practical; Should I parse the array and save it as a string to a certain field so that I can get the array back while fetching?

If so, which one would be better : serialize or json_encode.

While I heard serialize is not reliable all the time, json_encode's purpose is not the same what I am going to use.

Briefly, I want to store a dynamic associative array against a node.

Any suggestion?

share|improve this question
up vote 4 down vote accepted

serialize is better for small array, cuz unserialize will work faster. So if you work with huge data use json_encode &json_decode. Comparison PHP Serialization vs JSON Encoding for an array and your question already answered here on stackoverflow you can find more information about your question.

share|improve this answer
Define small array – AlxVallejo Jun 7 '14 at 13:48

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.