Search code examples
phpmysqlarraysserializationimplode

Serialize vs Implode


What do you think is the better way to go about storing a few image id's inside a record in a MySQL database? It's just the image id's which will be used to fetch the images from a different library.

Do i implode the id's in the record like 1#4#7#9#10#12 or do I just serialize the array and store that? Are there any performance benefits by using the one instead of the other? Stability preferences?

I have just always used implode and explode, never really gave it much thought. Thanks.


Solution

  • I would pefer serialize or JSON-encode.
    It is more flexible and for example will allow you to add image title and other details there in future...