Vinc199789 Vinc199789 - 1 year ago 72
MySQL Question

How to store a array in a database?

I am trying to learn php databases and I have a question. How do I store an array in a database? I saw an answer on stackoverflow and there were they doing something with type

and in an other answer they were talking about creating a table for every user but I can't find a solution.

So summarized. I want to store an array in a database. I have acces to phpmyadmin so from there can I set the value type. and I would like to store that array in one column.

Can somebody help me solving the problem?

edit one: The things I want to store are music tags. So in code it would be something like this:


I want to store It in one column to make it easy searchable

Mir Mir
Answer Source

Usually you shouldn't store arrays in a single column in a db. It is preferable to have a table with tags and another one that links your entity with its tags. So, before try to store an array in a table just think if it is really the right thing to do in your specific case (usually not).

If you are sure you want to do that then you have serialize ans unserialize functions.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download