Take the 2-minute tour ×
Drupal Answers is a question and answer site for Drupal developers and administrators. It's 100% free, no registration required.

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

1 Answer 1

up vote 3 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 at 13:48

Your Answer

 
discard

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.