4

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?

5

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.

  • Define small array – AlxVallejo Jun 7 '14 at 13:48
  • The first link 404's. :( – Citricguy Jun 11 '18 at 10:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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